// File: /workspace/github_cpp_makefile_star2_O3/gvaumour[P]cache-simulator/src/Hierarchy.cc
// Function: Hierarchy::Hierarchy(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int)
Hierarchy::Hierarchy(string policy, int nbCores)
{
	ConfigCache L1Dataconfig (32768, 4 , BLOCK_SIZE , "LRU", 0);
	vector<ConfigCache> firstLevel;
	firstLevel.push_back(L1Dataconfig);

	ConfigCache L1Instconfig = L1Dataconfig;
	firstLevel.push_back(L1Instconfig);

	int nb_sets = simu_parameters.nb_sets;
	int nvm_assoc = simu_parameters.nvm_assoc;
	int sram_assoc = simu_parameters.sram_assoc;

	ConfigCache L2config ( (nvm_assoc+sram_assoc)*BLOCK_SIZE*nb_sets , sram_assoc + nvm_assoc, \
				BLOCK_SIZE , policy , nvm_assoc);
	L2config.m_printStats = true;
	vector<ConfigCache> secondLevelConfig;
	secondLevelConfig.push_back(L2config);
	
		
	m_nbLevel = 2;
	m_nbCores = nbCores;
//	m_private_caches.resize(m_nbCores);
	
	m_directory = new Directory();
	
	m_prefetcher = NULL;
	if(simu_parameters.enablePrefetch)
		m_prefetcher = new SimplePrefetcher( simu_parameters.prefetchDegree , simu_parameters.prefetchStreams , true);

	stats_beginTimeFrame = 0;
	
	for(unsigned i = 0 ; i < m_nbCores ; i++){
		m_private_caches.push_back(new Level(i , firstLevel, this) );
	}

	m_LLC = new Level(-1, secondLevelConfig , this);
	
	m_start_index = log2(BLOCK_SIZE)-1;
	
	stats_cleanWB_MainMem = 0;
	stats_dirtyWB_MainMem = 0;
	stats_writeMainMem = 0;
	stats_readMainMem = 0;
	
	stats_hitsPrefetch = 0;
	stats_issuedPrefetchs = 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
xorl %eax, %eax
movq %rax, 0x10(%rdi)
leaq 0x48(%rdi), %r12
movq %r12, 0x38(%rdi)
movq %rax, 0x40(%rdi)
movb $0x0, 0x48(%rdi)
leaq 0xa0(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1ee88(%rip), %rsi     # 0x3536e
leaq 0x1ee84(%rip), %rdx     # 0x35371
leaq 0x90(%rsp), %rdi
movq %r12, 0x40(%rsp)
callq 0xcc6c
movabsq $0x400008000, %rax      # imm = 0x400008000
leaq 0x18(%rsp), %rdi
movq %rax, -0x10(%rdi)
movl $0x40, -0x8(%rdi)
leaq 0x28(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rdx
addq %rsi, %rdx
callq 0xcbd6
movl $0x0, 0x38(%rsp)
movb $0x0, 0x3c(%rsp)
movq 0x90(%rsp), %rdi
cmpq %r15, %rdi
je 0x16559
callq 0x52b0
xorps %xmm0, %xmm0
leaq 0x70(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
leaq 0x8(%rsp), %rsi
callq 0x17ebe
movq 0x8(%rsp), %rax
leaq 0x140(%rsp), %rdi
movq %rax, -0x10(%rdi)
movl 0x10(%rsp), %eax
movl %eax, -0x8(%rdi)
leaq 0x150(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
addq %rsi, %rdx
callq 0xcbd6
movl %ebp, 0x4(%rsp)
movl 0x38(%rsp), %eax
leaq 0x130(%rsp), %rsi
movl %eax, 0x30(%rsi)
movb 0x3c(%rsp), %al
movb %al, 0x34(%rsi)
leaq 0x70(%rsp), %rdi
callq 0x17ebe
leaq 0x2f979(%rip), %r12     # 0x45f50
movl 0x44(%r12), %r15d
movl 0x38(%r12), %ebp
movl 0x40(%r12), %r13d
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x50(%rsp), %rdi
callq 0xcbd6
addl %r13d, %ebp
imull %ebp, %r15d
shll $0x6, %r15d
leaq 0xf0(%rsp), %rdi
movl %r15d, -0x10(%rdi)
movl %ebp, -0xc(%rdi)
movl $0x40, -0x8(%rdi)
leaq 0x100(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
addq %rsi, %rdx
callq 0xcbd6
movl %r13d, 0x110(%rsp)
movb $0x0, 0x114(%rsp)
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
movl 0x4(%rsp), %r14d
je 0x1666b
callq 0x52b0
leaq 0xe0(%rsp), %rsi
movb $0x1, 0x34(%rsi)
xorps %xmm0, %xmm0
leaq 0xb0(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
callq 0x17ebe
movl $0x2, 0x30(%rbx)
movl %r14d, 0x34(%rbx)
movl $0x30, %edi
callq 0x52f0
movq %rax, %r15
movq %rax, %rdi
callq 0x12f0a
movq %r15, 0x20(%rbx)
movq $0x0, 0x28(%rbx)
cmpb $0x1, 0x8b(%r12)
jne 0x166f7
movl $0x30, %edi
callq 0x52f0
movq %rax, %r15
movl 0x8c(%r12), %esi
movl 0x90(%r12), %edx
movq %rax, %rdi
movl $0x1, %ecx
callq 0x28f24
movq %r15, 0x28(%rbx)
movq $0x0, 0x68(%rbx)
cmpl $0x0, 0x34(%rbx)
je 0x16774
xorl %ebp, %ebp
leaq 0x118(%rsp), %r14
leaq 0x70(%rsp), %r15
leaq 0x48(%rsp), %r12
movl $0x28, %edi
callq 0x52f0
movq %rax, %r13
movq %r14, %rdi
movq %r15, %rsi
callq 0x17f28
movq %r13, %rdi
movl %ebp, %esi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x1e8b8
movq %r13, 0x48(%rsp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x1675a
movq %r13, (%rsi)
addq $0x8, 0x8(%rbx)
jmp 0x16765
movq %rbx, %rdi
movq %r12, %rdx
callq 0x1846c
movq %r14, %rdi
callq 0x17fba
incl %ebp
cmpl 0x34(%rbx), %ebp
jb 0x16719
movl $0x28, %edi
callq 0x52f0
movq %rax, %r15
leaq 0xc8(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x17f28
leaq 0xc8(%rsp), %rdx
movq %r15, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movq %rbx, %rcx
callq 0x1e8b8
movq %r15, 0x18(%rbx)
leaq 0xc8(%rsp), %rdi
callq 0x17fba
movl $0x5, 0x60(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x70(%rbx)
movups %xmm0, 0x80(%rbx)
movups %xmm0, 0x90(%rbx)
leaq 0xb0(%rsp), %rdi
callq 0x17fba
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x16802
callq 0x52b0
movq 0x140(%rsp), %rdi
leaq 0x150(%rsp), %rax
cmpq %rax, %rdi
je 0x1681c
callq 0x52b0
leaq 0x70(%rsp), %rdi
callq 0x17fba
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x1683a
callq 0x52b0
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x16862
movq %rax, %r14
leaq 0xc8(%rsp), %rdi
callq 0x17fba
jmp 0x16865
jmp 0x16862
movq %rax, %r14
movq %r15, %rdi
jmp 0x168e2
movq %rax, %r14
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
jmp 0x16904
jmp 0x1687e
movq %rax, %r14
jmp 0x1690e
jmp 0x16888
movq %rax, %r14
jmp 0x16928
movq %rax, %r14
movq 0x90(%rsp), %rdi
cmpq %r15, %rdi
jne 0x16941
jmp 0x16946
movq %rax, %r14
jmp 0x16946
jmp 0x168c5
movq %rax, %r14
leaq 0x118(%rsp), %rdi
callq 0x17fba
jmp 0x168e7
movq %rax, %r14
jmp 0x168e7
movq %rax, %r14
jmp 0x168df
movq %rax, %r14
leaq 0x118(%rsp), %rdi
callq 0x17fba
movq %r13, %rdi
callq 0x52b0
leaq 0xb0(%rsp), %rdi
callq 0x17fba
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x1690e
callq 0x52b0
movq 0x140(%rsp), %rdi
leaq 0x150(%rsp), %rax
cmpq %rax, %rdi
je 0x16928
callq 0x52b0
leaq 0x70(%rsp), %rdi
callq 0x17fba
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x16946
callq 0x52b0
movq 0x38(%rbx), %rdi
cmpq 0x40(%rsp), %rdi
je 0x16956
callq 0x52b0
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x16963
callq 0x52b0
movq %r14, %rdi
callq 0x55a0
nop