summaryrefslogtreecommitdiff
path: root/src/arch/mips/isa/formats
diff options
context:
space:
mode:
authorGabe Black <gblack@eecs.umich.edu>2011-09-19 06:14:02 -0700
committerGabe Black <gblack@eecs.umich.edu>2011-09-19 06:14:02 -0700
commitf21ae529fb56592a7557a6583e68d8aae0d64adc (patch)
tree5bca6c6c615faea84c67c8dcb089c3b46f219597 /src/arch/mips/isa/formats
parent4ad36a4684c554bce2c9e3780f51c58195fe8205 (diff)
downloadgem5-f21ae529fb56592a7557a6583e68d8aae0d64adc.tar.xz
MIPS: Get rid of #if style config checks in the ISA description.
Diffstat (limited to 'src/arch/mips/isa/formats')
-rw-r--r--src/arch/mips/isa/formats/control.isa126
-rwxr-xr-xsrc/arch/mips/isa/formats/dsp.isa22
-rw-r--r--src/arch/mips/isa/formats/fp.isa17
-rw-r--r--src/arch/mips/isa/formats/mem.isa16
-rw-r--r--src/arch/mips/isa/formats/unimp.isa67
5 files changed, 109 insertions, 139 deletions
diff --git a/src/arch/mips/isa/formats/control.isa b/src/arch/mips/isa/formats/control.isa
index cb5b4372f..7e90ed3e5 100644
--- a/src/arch/mips/isa/formats/control.isa
+++ b/src/arch/mips/isa/formats/control.isa
@@ -124,30 +124,28 @@ def template CP1Execute {{
def template ControlTLBExecute {{
Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
{
- Fault fault = NoFault;
- %(op_decl)s;
- %(op_rd)s;
+ Fault fault = NoFault;
+ %(op_decl)s;
+ %(op_rd)s;
-#if FULL_SYSTEM
+ if (FULL_SYSTEM) {
if (isCoprocessor0Enabled(xc)) {
- if(isMMUTLB(xc)){
- %(code)s;
- } else {
- fault = new ReservedInstructionFault();
- }
+ if(isMMUTLB(xc)){
+ %(code)s;
+ } else {
+ fault = new ReservedInstructionFault();
+ }
} else {
- fault = new CoprocessorUnusableFault(0);
+ fault = new CoprocessorUnusableFault(0);
}
-#else // Syscall Emulation Mode - No TLB Instructions
+ } else { // Syscall Emulation Mode - No TLB Instructions
fault = new ReservedInstructionFault();
-#endif
-
- if(fault == NoFault)
- {
- %(op_wb)s;
- }
- return fault;
+ }
+ if (fault == NoFault) {
+ %(op_wb)s;
+ }
+ return fault;
}
}};
@@ -175,67 +173,49 @@ output decoder {{
}};
output exec {{
- bool isCoprocessorEnabled(%(CPU_exec_context)s *xc, unsigned cop_num)
+ bool
+ isCoprocessorEnabled(%(CPU_exec_context)s *xc, unsigned cop_num)
{
-#if !FULL_SYSTEM
- return true;
-#else
- MiscReg Stat = xc->readMiscReg(MISCREG_STATUS);
- switch(cop_num)
- {
- case 0:
- {
- MiscReg Dbg = xc->readMiscReg(MISCREG_DEBUG);
- if((Stat & 0x10000006) == 0 // EXL, ERL or CU0 set, CP0 accessible
- && (Dbg & 0x40000000) == 0 // DM bit set, CP0 accessible
- && (Stat & 0x00000018) != 0) { // KSU = 0, kernel mode is base mode
- // Unable to use Status_CU0, etc directly, using bitfields & masks
- return false;
- }
-
- }
- break;
- case 1:
- if((Stat & 0x20000000) == 0) // CU1 is reset
- return false;
- break;
- case 2:
- if((Stat & 0x40000000) == 0) // CU2 is reset
- return false;
- break;
- case 3:
- if((Stat & 0x80000000) == 0) // CU3 is reset
- return false;
- break;
- default: panic("Invalid Coprocessor Number Specified");
- break;
+ if (!FULL_SYSTEM)
+ return true;
+
+ MiscReg Stat = xc->readMiscReg(MISCREG_STATUS);
+ if (cop_num == 0) {
+ MiscReg Dbg = xc->readMiscReg(MISCREG_DEBUG);
+ // In Stat, EXL, ERL or CU0 set, CP0 accessible
+ // In Dbg, DM bit set, CP0 accessible
+ // In Stat, KSU = 0, kernel mode is base mode
+ return (Stat & 0x10000006) ||
+ (Dbg & 0x40000000) ||
+ !(Stat & 0x00000018);
+ } else if (cop_num < 4) {
+ return Stat & (0x10000000 << cop_num); // CU is reset
+ } else {
+ panic("Invalid Coprocessor Number Specified");
}
- return true;
-#endif
}
- bool inline isCoprocessor0Enabled(%(CPU_exec_context)s *xc)
+
+ bool inline
+ isCoprocessor0Enabled(%(CPU_exec_context)s *xc)
{
-#if FULL_SYSTEM
- MiscReg Stat = xc->readMiscRegNoEffect(MISCREG_STATUS);
- MiscReg Dbg = xc->readMiscRegNoEffect(MISCREG_DEBUG);
- if((Stat & 0x10000006) == 0 // EXL, ERL or CU0 set, CP0 accessible
- && (Dbg & 0x40000000) == 0 // DM bit set, CP0 accessible
- && (Stat & 0x00000018) != 0) { // KSU = 0, kernel mode is base mode
- // Unable to use Status_CU0, etc directly, using bitfields & masks
- return false;
- }
-#else
- //printf("Syscall Emulation Mode: CP0 Enable Check defaults to TRUE\n");
-#endif
- return true;
+ if (FULL_SYSTEM) {
+ MiscReg Stat = xc->readMiscReg(MISCREG_STATUS);
+ MiscReg Dbg = xc->readMiscReg(MISCREG_DEBUG);
+ // In Stat, EXL, ERL or CU0 set, CP0 accessible
+ // In Dbg, DM bit set, CP0 accessible
+ // In Stat KSU = 0, kernel mode is base mode
+ return (Stat & 0x10000006) || (Dbg & 0x40000000) ||
+ !(Stat & 0x00000018);
+ } else {
+ return true;
+ }
}
- bool isMMUTLB(%(CPU_exec_context)s *xc)
+
+ bool
+ isMMUTLB(%(CPU_exec_context)s *xc)
{
-#if FULL_SYSTEM
- if((xc->readMiscRegNoEffect(MISCREG_CONFIG) & 0x00000380)==0x80)
- return true;
-#endif
- return false;
+ MiscReg Config = xc->readMiscReg(MISCREG_CONFIG);
+ return FULL_SYSTEM && (Config & 0x380) == 0x80;
}
}};
diff --git a/src/arch/mips/isa/formats/dsp.isa b/src/arch/mips/isa/formats/dsp.isa
index 7d16b4162..2eeefe806 100755
--- a/src/arch/mips/isa/formats/dsp.isa
+++ b/src/arch/mips/isa/formats/dsp.isa
@@ -140,28 +140,18 @@ output decoder {{
}};
output exec {{
- bool isDspEnabled(%(CPU_exec_context)s *xc)
+ bool
+ isDspEnabled(%(CPU_exec_context)s *xc)
{
-#if FULL_SYSTEM
- if( bits( xc->readMiscReg(MISCREG_STATUS), 24, 24 ) == 0 )
- return false;
-#else
- //printf("Syscall Emulation Mode: isDspEnabled() check defaults to TRUE\n");
-#endif
- return true;
+ return !FULL_SYSTEM || bits(xc->readMiscReg(MISCREG_STATUS), 24);
}
}};
output exec {{
- bool isDspPresent(%(CPU_exec_context)s *xc)
+ bool
+ isDspPresent(%(CPU_exec_context)s *xc)
{
-#if FULL_SYSTEM
- if( bits( xc->readMiscReg(MISCREG_CONFIG3), 10, 10 ) == 0 )
- return false;
-#else
- //printf("Syscall Emulation Mode: isDspPresent() check defaults to TRUE\n");
-#endif
- return true;
+ return !FULL_SYSTEM || bits(xc->readMiscReg(MISCREG_CONFIG3), 10);
}
}};
diff --git a/src/arch/mips/isa/formats/fp.isa b/src/arch/mips/isa/formats/fp.isa
index 72d87f997..dcea32a36 100644
--- a/src/arch/mips/isa/formats/fp.isa
+++ b/src/arch/mips/isa/formats/fp.isa
@@ -174,9 +174,8 @@ def template FloatingPointExecute {{
//When is the right time to reset cause bits?
//start of every instruction or every cycle?
-#if FULL_SYSTEM
- fpResetCauseBits(xc);
-#endif
+ if (FULL_SYSTEM)
+ fpResetCauseBits(xc);
%(op_decl)s;
%(op_rd)s;
@@ -191,12 +190,12 @@ def template FloatingPointExecute {{
//----
//Check for IEEE 754 FP Exceptions
//fault = fpNanOperands((FPOp*)this, xc, Fd, traceData);
- if (
-#if FULL_SYSTEM
- !fpInvalidOp((FPOp*)this, xc, Fd, traceData) &&
-#endif
- fault == NoFault)
- {
+ bool invalid_op = false;
+ if (FULL_SYSTEM) {
+ invalid_op =
+ fpInvalidOp((FPOp*)this, xc, Fd, traceData);
+ }
+ if (!invalid_op && fault == NoFault) {
%(op_wb)s;
}
}
diff --git a/src/arch/mips/isa/formats/mem.isa b/src/arch/mips/isa/formats/mem.isa
index bc3a2b3ce..22296bc3b 100644
--- a/src/arch/mips/isa/formats/mem.isa
+++ b/src/arch/mips/isa/formats/mem.isa
@@ -542,12 +542,13 @@ def format StoreFPIndexedMemory(memacc_code, ea_code = {{ EA = Rs + Rt; }},
def format LoadUnalignedMemory(memacc_code, ea_code = {{ EA = (Rs + disp) & ~3; }},
mem_flags = [], inst_flags = []) {{
- decl_code = 'uint32_t mem_word = Mem.uw;\n'
- decl_code += 'uint32_t unalign_addr = Rs + disp;\n'
- decl_code += 'uint32_t byte_offset = unalign_addr & 3;\n'
- decl_code += '#if BYTE_ORDER == BIG_ENDIAN\n'
- decl_code += '\tbyte_offset ^= 3;\n'
- decl_code += '#endif\n'
+ decl_code = '''
+ uint32_t mem_word = Mem.uw;
+ uint32_t unalign_addr = Rs + disp;
+ uint32_t byte_offset = unalign_addr & 3;
+ if (GuestByteOrder == BigEndianByteOrder)
+ byte_offset ^= 3;
+ '''
memacc_code = decl_code + memacc_code
@@ -563,9 +564,8 @@ def format StoreUnalignedMemory(memacc_code, ea_code = {{ EA = (Rs + disp) & ~3;
uint32_t mem_word = 0;
uint32_t unaligned_addr = Rs + disp;
uint32_t byte_offset = unaligned_addr & 3;
- #if BYTE_ORDER == BIG_ENDIAN
+ if (GuestByteOrder == BigEndianByteOrder)
byte_offset ^= 3;
- #endif
fault = readMemAtomic(xc, traceData, EA, mem_word, memAccessFlags);
'''
memacc_code = decl_code + memacc_code + '\nMem = mem_word;\n'
diff --git a/src/arch/mips/isa/formats/unimp.isa b/src/arch/mips/isa/formats/unimp.isa
index 2cee38a4b..e599510a4 100644
--- a/src/arch/mips/isa/formats/unimp.isa
+++ b/src/arch/mips/isa/formats/unimp.isa
@@ -193,50 +193,51 @@ output exec {{
CP0Unimplemented::execute(%(CPU_exec_context)s *xc,
Trace::InstRecord *traceData) const
{
-#if FULL_SYSTEM
- if (!isCoprocessorEnabled(xc, 0)) {
- return new CoprocessorUnusableFault(0);
- }
- return new ReservedInstructionFault;
-#else
- panic("attempt to execute unimplemented instruction '%s' "
- "(inst 0x%08x, opcode 0x%x, binary:%s)", mnemonic, machInst, OPCODE,
- inst2string(machInst));
- return new UnimplementedOpcodeFault;
-#endif
+ if (FULL_SYSTEM) {
+ if (!isCoprocessorEnabled(xc, 0))
+ return new CoprocessorUnusableFault(0);
+ else
+ return new ReservedInstructionFault;
+ } else {
+ panic("attempt to execute unimplemented instruction '%s' "
+ "(inst %#08x, opcode %#x, binary:%s)",
+ mnemonic, machInst, OPCODE, inst2string(machInst));
+ return new UnimplementedOpcodeFault;
+ }
}
Fault
CP1Unimplemented::execute(%(CPU_exec_context)s *xc,
Trace::InstRecord *traceData) const
{
-#if FULL_SYSTEM
- if (!isCoprocessorEnabled(xc, 1)) {
- return new CoprocessorUnusableFault(1);
- }
- return new ReservedInstructionFault;
-#else
- panic("attempt to execute unimplemented instruction '%s' "
- "(inst 0x%08x, opcode 0x%x, binary:%s)", mnemonic, machInst, OPCODE,
- inst2string(machInst));
- return new UnimplementedOpcodeFault;
-#endif
+ if (FULL_SYSTEM) {
+ if (!isCoprocessorEnabled(xc, 1))
+ return new CoprocessorUnusableFault(1);
+ else
+ return new ReservedInstructionFault;
+ } else {
+ panic("attempt to execute unimplemented instruction '%s' "
+ "(inst %#08x, opcode %#x, binary:%s)",
+ mnemonic, machInst, OPCODE, inst2string(machInst));
+ return new UnimplementedOpcodeFault;
+ }
}
+
Fault
CP2Unimplemented::execute(%(CPU_exec_context)s *xc,
Trace::InstRecord *traceData) const
{
-#if FULL_SYSTEM
- if (!isCoprocessorEnabled(xc, 2)) {
- return new CoprocessorUnusableFault(2);
- }
- return new ReservedInstructionFault;
-#else
- panic("attempt to execute unimplemented instruction '%s' "
- "(inst 0x%08x, opcode 0x%x, binary:%s)", mnemonic, machInst, OPCODE,
- inst2string(machInst));
- return new UnimplementedOpcodeFault;
-#endif
+ if (FULL_SYSTEM) {
+ if (!isCoprocessorEnabled(xc, 2))
+ return new CoprocessorUnusableFault(2);
+ else
+ return new ReservedInstructionFault;
+ } else {
+ panic("attempt to execute unimplemented instruction '%s' "
+ "(inst %#08x, opcode %#x, binary:%s)",
+ mnemonic, machInst, OPCODE, inst2string(machInst));
+ return new UnimplementedOpcodeFault;
+ }
}
Fault