Exemplo n.º 1
0
int mapRegisterTemp(void){
	// Try to find an already available register
	int available = getAvailableHWReg();
	if(available >= 0) return available;
	// If there are none, flush the LRU and use it
	RegMapping lru = flushLRURegister();
	if(lru.hi >= 0) availableRegs[lru.hi] = 1;
	return lru.lo;
}
Exemplo n.º 2
0
RegMapping mapRegister64New(int gpr){
	if(!gpr) return (RegMapping){ 0, 0 };
	regMap[gpr].lru = nextLRUVal++;
	regMap[gpr].sign = 1;
	regMap[gpr].dirty = 1; // Since we're writing to this reg, its dirty
	regMap[gpr].constant = 0; // This is a dynamic or unknowable value
	
	// If its already been mapped, just return that value
	if(regMap[gpr].map.lo >= 0){
		// If the hi value is not mapped, find a mapping
		if(regMap[gpr].map.hi < 0){
			// Try to find any already available register
			int available = getAvailableHWReg();
			if(available >= 0) regMap[gpr].map.hi = available;
			else {
				// We didn't find an available register, so flush one
				RegMapping lru = flushLRURegister();
				if(lru.hi >= 0) availableRegs[lru.hi] = 1;
				regMap[gpr].map.hi = lru.lo;
			}
		}
		// Return the mapping
		return regMap[gpr].map;
	}
	
	// Try to find any already available registers
	regMap[gpr].map.hi = getAvailableHWReg();
	regMap[gpr].map.lo = getAvailableHWReg();
	// If there weren't enough registers, we'll have to flush
	if(regMap[gpr].map.lo < 0){
		// We didn't find any available registers, so flush one
		RegMapping lru = flushLRURegister();
		if(lru.hi >= 0) regMap[gpr].map.hi = lru.hi;
		regMap[gpr].map.lo = lru.lo;
	}
	if(regMap[gpr].map.hi < 0){
		// We didn't find an available register, so flush one
		RegMapping lru = flushLRURegister();
		if(lru.hi >= 0) availableRegs[lru.hi] = 1;
		regMap[gpr].map.hi = lru.lo;
	}
	// Return the mapping
	return regMap[gpr].map;
}
Exemplo n.º 3
0
int mapRegisterNew(int reg){
	if(!reg) return 0; // Discard any writes to r0
	regMap[reg].lru = nextLRUVal++;
	regMap[reg].dirty = 1; // Since we're writing to this reg, its dirty
	
	// If its already been mapped, just return that value
	if(regMap[reg].map.lo >= 0){
		// If the hi value is mapped, free the mapping
		if(regMap[reg].map.hi >= 0){
			availableRegs[regMap[reg].map.hi] = 1;
			regMap[reg].map.hi = -1;
		}
		return regMap[reg].map.lo;
	}
	
	// Try to find any already available register
	int available = getAvailableHWReg();
	if(available >= 0) return regMap[reg].map.lo = available;
	// We didn't find an available register, so flush one
	RegMapping lru = flushLRURegister();
	if(lru.hi >= 0) availableRegs[lru.hi] = 1;
	
	return regMap[reg].map.lo = lru.lo;
}