// File: /workspace/github_cpp_makefile_star2_O2/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
andq $0x0, 0x10(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
leaq 0x48(%rdi), %rax
movq %rax, 0x38(%rdi)
andq $0x0, 0x40(%rdi)
movb $0x0, 0x48(%rdi)
leaq 0x17e94(%rip), %rsi     # 0x2a31a
leaq 0x88(%rsp), %rdi
leaq 0xa8(%rsp), %rdx
callq 0x5140
leaq 0xe0(%rsp), %rdi
pushq $0x4
popq %rdx
pushq $0x40
popq %rcx
leaq 0x88(%rsp), %r8
movl $0x8000, %esi           # imm = 0x8000
xorl %r9d, %r9d
callq 0x13912
leaq 0x88(%rsp), %rdi
callq 0x5618
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rdi
movaps %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
leaq 0xe0(%rsp), %rsi
callq 0x13942
leaq 0xa8(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x1396e
movl %ebp, 0x4(%rsp)
leaq 0x10(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x13942
leaq 0x2ba36(%rip), %rbp     # 0x3df50
movl 0x44(%rbp), %r13d
movl 0x38(%rbp), %r12d
movl 0x40(%rbp), %r15d
leaq 0x68(%rsp), %rdi
movq %r14, %rsi
callq 0x5410
addl %r15d, %r12d
imull %r12d, %r13d
shll $0x6, %r13d
leaq 0x130(%rsp), %rdi
pushq $0x40
popq %rcx
leaq 0x68(%rsp), %r8
movl %r13d, %esi
movl %r12d, %edx
movl %r15d, %r9d
callq 0x13912
leaq 0x68(%rsp), %rdi
callq 0x5618
leaq 0x130(%rsp), %rsi
movb $0x1, 0x34(%rsi)
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rdi
movaps %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
callq 0x13942
movl $0x2, 0x30(%rbx)
movl 0x4(%rsp), %eax
movl %eax, 0x34(%rbx)
pushq $0x30
popq %rdi
callq 0x52e0
movq %rax, %r15
movq %rax, %rdi
callq 0xfa4a
movq %r15, 0x20(%rbx)
andq $0x0, 0x28(%rbx)
cmpb $0x1, 0x8b(%rbp)
jne 0x125e0
pushq $0x30
popq %rdi
callq 0x52e0
movq %rax, %r15
movl 0x8c(%rbp), %esi
movl 0x90(%rbp), %edx
pushq $0x1
popq %rcx
movq %rax, %rdi
callq 0x21420
movq %r15, 0x28(%rbx)
andq $0x0, 0x68(%rbx)
xorl %ebp, %ebp
leaq 0x118(%rsp), %r12
leaq 0x8(%rsp), %r14
cmpl 0x34(%rbx), %ebp
jae 0x12643
pushq $0x28
popq %rdi
callq 0x52e0
movq %rax, %r15
movq %r12, %rdi
leaq 0x10(%rsp), %rsi
callq 0x139a8
movb $0x1, %r13b
movq %r15, %rdi
movl %ebp, %esi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x1926c
movq %r15, 0x8(%rsp)
xorl %r13d, %r13d
movq %rbx, %rdi
movq %r14, %rsi
callq 0x13da0
movq %r12, %rdi
callq 0x13a02
incl %ebp
jmp 0x125f4
pushq $0x28
popq %rdi
callq 0x52e0
movq %rax, %r15
leaq 0x50(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x139a8
pushq $-0x1
popq %rsi
leaq 0x50(%rsp), %rdx
movq %r15, %rdi
movq %rbx, %rcx
callq 0x1926c
movq %r15, 0x18(%rbx)
leaq 0x50(%rsp), %rdi
callq 0x13a02
movl $0x5, 0x60(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x70(%rbx)
movups %xmm0, 0x80(%rbx)
movups %xmm0, 0x90(%rbx)
leaq 0x30(%rsp), %rdi
callq 0x13a02
leaq 0x140(%rsp), %rdi
callq 0x5618
leaq 0xb8(%rsp), %rdi
callq 0x5618
leaq 0x10(%rsp), %rdi
callq 0x13a02
leaq 0xf0(%rsp), %rdi
callq 0x5618
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1272d
movq %rax, %r14
leaq 0x50(%rsp), %rdi
callq 0x13a02
jmp 0x12747
jmp 0x1272d
jmp 0x1272d
movq %rax, %r14
leaq 0x68(%rsp), %rdi
jmp 0x12761
jmp 0x12708
movq %rax, %r14
jmp 0x12766
jmp 0x1270f
movq %rax, %r14
jmp 0x12773
movq %rax, %r14
leaq 0x88(%rsp), %rdi
jmp 0x12785
movq %rax, %r14
jmp 0x1278a
jmp 0x12728
movq %rax, %r14
jmp 0x1274f
movq %rax, %r14
jmp 0x12747
movq %rax, %r14
leaq 0x118(%rsp), %rdi
callq 0x13a02
testb %r13b, %r13b
je 0x1274f
movq %r15, %rdi
callq 0x52a0
leaq 0x30(%rsp), %rdi
callq 0x13a02
leaq 0x140(%rsp), %rdi
callq 0x5618
leaq 0xb8(%rsp), %rdi
callq 0x5618
leaq 0x10(%rsp), %rdi
callq 0x13a02
leaq 0xf0(%rsp), %rdi
callq 0x5618
leaq 0x38(%rbx), %rdi
callq 0x5618
movq %rbx, %rdi
callq 0x13a24
movq %r14, %rdi
callq 0x5570
nop