// File: gvaumour[P]cache-simulator/src/Predictor.cc
// Function: Predictor::insertionPolicy(unsigned long, unsigned long, bool, Access)
void
Predictor::insertionPolicy(uint64_t set, uint64_t index, bool inNVM, Access element)
{
	CacheEntry* entry = inNVM ? m_tableNVM[set][index] : m_tableSRAM[set][index];
	uint64_t block_addr = bitRemove(element.m_address , 0 , log2(BLOCK_SIZE));
	updateFUcaches(block_addr , inNVM);
	updateCachePressure();


	//Update the missing tag as a new cache line is brough into the cache 
	//Has to remove the MT entry if it exists there 
	//DPRINTF("Predictor::insertRecord Begin ");	
	if(m_trackError)
	{
		if( simu_parameters.enableFullSRAMtraffic )
		{
			//insertIntoSRAMMT(set , inNVM, element );
		}
		else
		{
			if(inNVM)
			{
				for(unsigned i = 0 ; i < m_SRAM_missing_tags[set].size(); i++)
				{
					if(m_SRAM_missing_tags[set][i]->addr == entry->address)
						m_SRAM_missing_tags[set][i]->isValid = false;
				}		
			}		
		}	
		updateBypassTag( entry , set, inNVM);
	}	
	//DPRINTF("Predictor::insertRecord Begin ");

}

// Assembly:
subq $0x68, %rsp
movb %cl, %al
leaq 0x70(%rsp), %rcx
movq %rcx, 0x20(%rsp)
movq %rdi, 0x60(%rsp)
movq %rsi, 0x58(%rsp)
movq %rdx, 0x50(%rsp)
andb $0x1, %al
movb %al, 0x4f(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x28(%rsp)
testb $0x1, 0x4f(%rsp)
je 0x551a0
movq 0x28(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x58(%rsp), %rsi
callq 0xf9a0
movq %rax, %rdi
movq 0x50(%rsp), %rsi
callq 0xf9c0
movq (%rax), %rax
movq %rax, 0x18(%rsp)
jmp 0x551c8
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x58(%rsp), %rsi
callq 0xf9a0
movq %rax, %rdi
movq 0x50(%rsp), %rsi
callq 0xf9c0
movq (%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x20(%rsp), %rax
movq 0x18(%rsp), %rcx
movq %rcx, 0x40(%rsp)
movq (%rax), %rax
movq %rax, 0x10(%rsp)
movl $0x40, %edi
callq 0x284e0
movq 0x10(%rsp), %rdi
cvttsd2si %xmm0, %rax
movl %eax, %edx
xorl %esi, %esi
callq 0x655b0
movq 0x28(%rsp), %rdi
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rsi
movb 0x4f(%rsp), %al
andb $0x1, %al
movzbl %al, %edx
callq 0x55330
movq 0x28(%rsp), %rdi
callq 0x55f00
movq 0x28(%rsp), %rax
testb $0x1, 0x80(%rax)
je 0x55326
leaq 0x3edb4(%rip), %rax     # 0x93ff0
testb $0x1, 0xdc(%rax)
je 0x5524a
jmp 0x55307
testb $0x1, 0x4f(%rsp)
je 0x55305
movl $0x0, 0x34(%rsp)
movq 0x28(%rsp), %rdi
movl 0x34(%rsp), %eax
movq %rax, 0x8(%rsp)
addq $0x88, %rdi
movq 0x58(%rsp), %rsi
callq 0x58920
movq %rax, %rdi
callq 0x58940
movq %rax, %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
jae 0x55303
movq 0x28(%rsp), %rdi
addq $0x88, %rdi
movq 0x58(%rsp), %rsi
callq 0x58920
movq %rax, %rdi
movl 0x34(%rsp), %eax
movl %eax, %esi
callq 0x58860
movq (%rax), %rax
movq (%rax), %rax
movq 0x40(%rsp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x552f1
movq 0x28(%rsp), %rdi
addq $0x88, %rdi
movq 0x58(%rsp), %rsi
callq 0x58920
movq %rax, %rdi
movl 0x34(%rsp), %eax
movl %eax, %esi
callq 0x58860
movq (%rax), %rax
movb $0x0, 0x14(%rax)
jmp 0x552f3
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
jmp 0x5525d
jmp 0x55305
jmp 0x55307
movq 0x28(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq 0x58(%rsp), %rax
movl %eax, %edx
movb 0x4f(%rsp), %al
andb $0x1, %al
movzbl %al, %ecx
callq 0x560c0
addq $0x68, %rsp
retq
nopl (%rax,%rax)