// File: /workspace/github_cpp_makefile_star2_O1/gvaumour[P]cache-simulator/src/Perceptron.cc
// Function: PerceptronPredictor::updatePolicy(unsigned long, unsigned long, bool, Access, bool)
void
PerceptronPredictor::updatePolicy(uint64_t set, uint64_t index, bool inNVM, Access element, bool isWBrequest)
{
	update_globalPChistory(element.m_pc);
	
	stats_update++;
	
	CacheEntry *entry = get_entry(set , index , inNVM);
	entry->policyInfo = m_cpt++;

	if(entry->isLearning)
	{
		if(m_enableBP)
		{
			stats_update_learning++;
			for(unsigned i = 0 ; i < m_BP_features.size() ; i++)
			{
				if( entry->perceptron_BPpred[i] > -simu_parameters.perceptron_bypass_learning || !entry->predictedReused[i])
					m_BP_features[i]->decreaseConfidence(entry->perceptron_BPHash[i]);
			}
			setBPPrediction(entry);
		}
		
		if(m_enableAllocation)
		{
			RD_TYPE rd_type = classifyRD(set , index , inNVM);
			
		
			if(rd_type == RD_SHORT && element.isWrite() && inNVM)
			{
				for(unsigned i = 0 ; i < m_Allocation_features.size() ; i++)
				{
					if( entry->perceptron_Allocpred[i] > - simu_parameters.perceptron_bypass_learning)
						m_Allocation_features[i]->decreaseConfidence(entry->perceptron_AllocHash[i]);
				}		
			}
			setAllocPrediction(entry);

		}
	}
	
	if(m_enableAllocation)
	{
		RD_TYPE rd_type = classifyRD(set , index , inNVM);
	
		for(unsigned i = 0 ; i < m_Allocation_features.size() ; i++)
		{
			int hash = m_Allocation_features_hash[i](entry->address , entry->m_pc);
			m_Allocation_features[i]->recordAccess( hash  , element.isWrite() , rd_type);
		}
	}

	
	stats_nbHits++;
	miss_counter--;
	if(miss_counter < 0)
		miss_counter = 0;


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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r8d, 0x24(%rsp)
movl %ecx, %ebp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x60(%rsp), %r12
movq 0x10(%r12), %rsi
callq 0x24704
incq 0x3d8(%r15)
movl %ebp, %eax
movq 0x8(%r15,%rax,8), %rax
movq (%rax), %rax
movq %r14, 0x10(%rsp)
leaq (%r14,%r14,2), %rcx
movq (%rax,%rcx,8), %rax
movq %rbx, 0x18(%rsp)
movq (%rax,%rbx,8), %r13
movq 0x308(%r15), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x308(%r15)
movl %eax, 0x38(%r13)
cmpb $0x1, 0x148(%r13)
movzbl %bpl, %eax
movl %eax, 0xc(%rsp)
jne 0x24a70
cmpb $0x1, 0x348(%r15)
jne 0x249bc
movq %r12, %r14
incq 0x3e0(%r15)
movq 0x2b8(%r15), %rax
cmpq %rax, 0x2c0(%r15)
je 0x249ae
movl $0x1, %r12d
xorl %ecx, %ecx
leaq 0x215fb(%rip), %rbx     # 0x45f50
movq 0x48(%r13), %rdx
xorl %esi, %esi
subl 0x1bc(%rbx), %esi
cmpl %esi, (%rdx,%rcx,4)
jg 0x2497e
movq 0xa8(%r13), %rdx
movq %rcx, %rsi
shrq $0x6, %rsi
movq (%rdx,%rsi,8), %rdx
btq %rcx, %rdx
jb 0x2498e
movq (%rax,%rcx,8), %rdi
movq 0x78(%r13), %rax
movl (%rax,%rcx,4), %esi
callq 0x14b12
movl %r12d, %ecx
movq 0x2b8(%r15), %rax
movq 0x2c0(%r15), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
incl %r12d
cmpq %rcx, %rdx
ja 0x24955
movq %r15, %rdi
movq %r13, %rsi
callq 0x24b6c
movq %r14, %r12
cmpb $0x1, 0x349(%r15)
jne 0x24a70
movq %r12, %r14
movq %r15, %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl 0xc(%rsp), %ecx
callq 0x24c40
testl %eax, %eax
jne 0x24a62
movl 0x1c(%r14), %eax
cmpl $0x3, %eax
sete %cl
cmpl $0x6, %eax
sete %al
orb %cl, %al
andb %bpl, %al
cmpb $0x1, %al
jne 0x24a62
movq 0x270(%r15), %rax
cmpq %rax, 0x278(%r15)
je 0x24a62
movl $0x1, %ebx
xorl %ecx, %ecx
leaq 0x21532(%rip), %r12     # 0x45f50
movq 0x60(%r13), %rdx
xorl %esi, %esi
subl 0x1bc(%r12), %esi
cmpl %esi, (%rdx,%rcx,4)
jle 0x24a44
movq (%rax,%rcx,8), %rdi
movq 0x90(%r13), %rax
movl (%rax,%rcx,4), %esi
callq 0x14b12
movl %ebx, %ecx
movq 0x270(%r15), %rax
movq 0x278(%r15), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
incl %ebx
cmpq %rcx, %rdx
ja 0x24a1e
movq %r15, %rdi
movq %r13, %rsi
callq 0x24d38
movq %r14, %r12
cmpb $0x1, 0x349(%r15)
jne 0x24b0b
movq %r15, %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl 0xc(%rsp), %ecx
callq 0x24c40
movl %eax, %ebp
movq 0x278(%r15), %rax
cmpq 0x270(%r15), %rax
je 0x24b0b
movl 0x1c(%r12), %eax
cmpl $0x3, %eax
sete %cl
cmpl $0x6, %eax
sete %al
orb %cl, %al
movl $0x1, %ebx
xorl %r14d, %r14d
movzbl %al, %r12d
movq 0x288(%r15), %rax
movq 0x8(%r13), %rdi
movq 0x10(%r13), %rsi
callq *(%rax,%r14,8)
movq 0x270(%r15), %rcx
movq (%rcx,%r14,8), %rdi
movl %eax, %esi
movl %r12d, %edx
movl %ebp, %ecx
callq 0x1464a
movq 0x278(%r15), %rax
subq 0x270(%r15), %rax
movl %ebx, %r14d
sarq $0x3, %rax
incl %ebx
cmpq %r14, %rax
ja 0x24ac5
incq 0x3a0(%r15)
leaq 0x21687(%rip), %rax     # 0x461a0
movl (%rax), %ecx
cmpl $0x2, %ecx
movl $0x1, %edx
cmovgel %ecx, %edx
decl %edx
movl %edx, (%rax)
movzbl 0x24(%rsp), %r8d
movq %r15, %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl 0xc(%rsp), %ecx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x275be