// File: gvaumour[P]cache-simulator/src/SimplePerceptron.cc
// Function: SimplePerceptronPredictor::updatePolicy(unsigned long, unsigned long, bool, Access, bool)
void
SimplePerceptronPredictor::updatePolicy(uint64_t set, uint64_t index, bool inNVM, Access element, bool isWBrequest)
{
	CacheEntry* entry = inNVM ? m_tableNVM[set][index] : m_tableSRAM[set][index];
//	RD_TYPE rd = classifyRD( set , index , inNVM );
//	stats_access_class[rd][element.isWrite()]++;
	
	entry->policyInfo = m_cpt++;
	Predictor::update_globalPChistory(element.m_pc);

	if(entry->isLearning)
	{
		updateCostModel(entry, entry->address , set , element.isWrite());
		if(simu_parameters.simple_perceptron_fastLearning)
		{
			doLearning(entry); //Update the dataset confidence
			setPrediction(entry, element); //Set the prediction ready for the next access
		}
	}

	if(simu_parameters.simple_perceptron_enableMigration)
	{
		assert(entry->isValid);
		entry = checkLazyMigration(entry , set , inNVM , index, element.isWrite());		
	}


	reportAccess( element, entry , set , inNVM, string("UPDATE") );

	Predictor::updatePolicy(set , index , inNVM , element , isWBrequest);
}

// Assembly:
subq $0x1c8, %rsp            # imm = 0x1C8
movb %r8b, %al
leaq 0x1d0(%rsp), %r8
movq %r8, 0xb0(%rsp)
movq %rdi, 0x1c0(%rsp)
movq %rsi, 0x1b8(%rsp)
movq %rdx, 0x1b0(%rsp)
andb $0x1, %cl
movb %cl, 0x1af(%rsp)
andb $0x1, %al
movb %al, 0x1ae(%rsp)
movq 0x1c0(%rsp), %rax
movq %rax, 0xb8(%rsp)
testb $0x1, 0x1af(%rsp)
je 0x623b5
movq 0xb8(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x1b8(%rsp), %rsi
callq 0xf9a0
movq %rax, %rdi
movq 0x1b0(%rsp), %rsi
callq 0xf9c0
movq (%rax), %rax
movq %rax, 0xa8(%rsp)
jmp 0x623e9
movq 0xb8(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x1b8(%rsp), %rsi
callq 0xf9a0
movq %rax, %rdi
movq 0x1b0(%rsp), %rsi
callq 0xf9c0
movq (%rax), %rax
movq %rax, 0xa8(%rsp)
movq 0xb8(%rsp), %rdi
movq 0xb0(%rsp), %rax
movq 0xa8(%rsp), %rcx
movq %rcx, 0x1a0(%rsp)
movq 0x2c0(%rdi), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, 0x2c0(%rdi)
movl %ecx, %edx
movq 0x1a0(%rsp), %rcx
movl %edx, 0x38(%rcx)
movq 0x10(%rax), %rsi
callq 0x573a0
movq 0x1a0(%rsp), %rax
testb $0x1, 0x148(%rax)
je 0x62551
movq 0xb0(%rsp), %rdi
movq 0x1a0(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x1a0(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x98(%rsp)
movq 0x1b8(%rsp), %rax
movl %eax, 0xa4(%rsp)
callq 0xf7c0
movq 0xb8(%rsp), %rdi
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rdx
movl 0xa4(%rsp), %ecx
movzbl %al, %r8d
andl $0x1, %r8d
callq 0x61160
leaq 0x31b34(%rip), %rax     # 0x93ff0
testb $0x1, 0x24c(%rax)
je 0x6254f
movq 0xb8(%rsp), %rdi
movq 0x1a0(%rsp), %rsi
callq 0x612e0
movq 0xb0(%rsp), %rsi
movq 0x1a0(%rsp), %rax
movq %rax, 0x88(%rsp)
leaq 0x168(%rsp), %rdi
movl $0x38, %edx
callq 0x52f0
movq 0xb8(%rsp), %rdi
movq 0x88(%rsp), %rsi
movq 0x198(%rsp), %rcx
movq %rsp, %rax
movq %rcx, 0x30(%rax)
movups 0x168(%rsp), %xmm0
movups 0x178(%rsp), %xmm1
movups 0x188(%rsp), %xmm2
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x61500
jmp 0x62551
leaq 0x31a98(%rip), %rax     # 0x93ff0
testb $0x1, 0x24e(%rax)
je 0x6260e
movq 0x1a0(%rsp), %rax
testb $0x1, (%rax)
je 0x62574
jmp 0x62593
leaq 0x10585(%rip), %rdi     # 0x72b00
leaq 0x11708(%rip), %rsi     # 0x73c8a
movl $0x8a, %edx
leaq 0x11714(%rip), %rcx     # 0x73ca2
callq 0x5260
movq 0xb0(%rsp), %rdi
movq 0x1a0(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x1b8(%rsp), %rax
movq %rax, 0x78(%rsp)
movb 0x1af(%rsp), %al
movb %al, 0x6f(%rsp)
movq 0x1b0(%rsp), %rax
movq %rax, 0x80(%rsp)
callq 0xf7c0
movb 0x6f(%rsp), %cl
movq 0xb8(%rsp), %rdi
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
movq 0x80(%rsp), %r8
movzbl %cl, %ecx
andl $0x1, %ecx
movzbl %al, %r9d
andl $0x1, %r9d
callq 0x62810
movq %rax, 0x1a0(%rsp)
movq 0xb0(%rsp), %rax
movq 0x30(%rax), %rcx
movq %rcx, 0x160(%rsp)
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movaps %xmm2, 0x150(%rsp)
movaps %xmm1, 0x140(%rsp)
movaps %xmm0, 0x130(%rsp)
movq 0x1a0(%rsp), %rax
movq %rax, 0x50(%rsp)
movl 0x1b8(%rsp), %eax
movl %eax, 0x58(%rsp)
movb 0x1af(%rsp), %al
movb %al, 0x5f(%rsp)
leaq 0x10f(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x56a0
movq 0x60(%rsp), %rdx
leaq 0xeb14(%rip), %rsi      # 0x7119a
leaq 0x110(%rsp), %rdi
callq 0x5530
jmp 0x62695
movl 0x58(%rsp), %edx
movq 0x50(%rsp), %rsi
movq 0xb8(%rsp), %rdi
movb 0x5f(%rsp), %al
movq 0x160(%rsp), %r8
movq %rsp, %rcx
movq %r8, 0x30(%rcx)
movaps 0x130(%rsp), %xmm0
movaps 0x140(%rsp), %xmm1
movaps 0x150(%rsp), %xmm2
movups %xmm2, 0x20(%rcx)
movups %xmm1, 0x10(%rcx)
movups %xmm0, (%rcx)
movzbl %al, %ecx
andl $0x1, %ecx
leaq 0x110(%rsp), %r8
callq 0x61740
jmp 0x626f1
leaq 0x110(%rsp), %rdi
callq 0x5768
leaq 0x10f(%rsp), %rdi
callq 0x53e0
movq 0xb0(%rsp), %rsi
movq 0x1b8(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x1b0(%rsp), %rax
movq %rax, 0x48(%rsp)
movb 0x1af(%rsp), %al
movb %al, 0x3f(%rsp)
leaq 0xc0(%rsp), %rdi
movl $0x38, %edx
callq 0x52f0
movb 0x3f(%rsp), %cl
movq 0xb8(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
movb 0x1ae(%rsp), %al
movq 0xf0(%rsp), %r9
movq %rsp, %r8
movq %r9, 0x30(%r8)
movups 0xc0(%rsp), %xmm0
movups 0xd0(%rsp), %xmm1
movups 0xe0(%rsp), %xmm2
movups %xmm2, 0x20(%r8)
movups %xmm1, 0x10(%r8)
movups %xmm0, (%r8)
movzbl %cl, %ecx
andl $0x1, %ecx
movzbl %al, %r8d
andl $0x1, %r8d
callq 0x56ed0
addq $0x1c8, %rsp            # imm = 0x1C8
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x100(%rsp)
movl %eax, 0xfc(%rsp)
jmp 0x627ee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x100(%rsp)
movl %eax, 0xfc(%rsp)
leaq 0x110(%rsp), %rdi
callq 0x5768
leaq 0x10f(%rsp), %rdi
callq 0x53e0
movq 0x100(%rsp), %rdi
callq 0x5690
nopl (%rax,%rax)