From: Gabe Black Date: Tue, 29 Oct 2019 23:12:37 +0000 (-0700) Subject: sparc: Replace htog and gtoh with htobe and betoh. X-Git-Tag: v19.0.0.0~320 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5a857378596c03ba9cb9024a3e701b27da18b7ef;p=gem5.git sparc: Replace htog and gtoh with htobe and betoh. We know what endianness to use when we're implicitly working with SPARC. Change-Id: I85eaac1da087a8086b9450b762a52323f2498e2e Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/22368 Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power Tested-by: kokoro --- diff --git a/src/arch/sparc/handlers.hh b/src/arch/sparc/handlers.hh index 274367cd3..561f7ee6d 100644 --- a/src/arch/sparc/handlers.hh +++ b/src/arch/sparc/handlers.hh @@ -44,146 +44,146 @@ const int numSpillInsts = 32; const MachInst fillHandler64[numFillInsts] = { - htog(0x87802016), // wr %g0, ASI_AIUP, %asi - htog(0xe0dba7ff), // ldxa [%sp + BIAS + (0*8)] %asi, %l0 - htog(0xe2dba807), // ldxa [%sp + BIAS + (1*8)] %asi, %l1 - htog(0xe4dba80f), // ldxa [%sp + BIAS + (2*8)] %asi, %l2 - htog(0xe6dba817), // ldxa [%sp + BIAS + (3*8)] %asi, %l3 - htog(0xe8dba81f), // ldxa [%sp + BIAS + (4*8)] %asi, %l4 - htog(0xeadba827), // ldxa [%sp + BIAS + (5*8)] %asi, %l5 - htog(0xecdba82f), // ldxa [%sp + BIAS + (6*8)] %asi, %l6 - htog(0xeedba837), // ldxa [%sp + BIAS + (7*8)] %asi, %l7 - htog(0xf0dba83f), // ldxa [%sp + BIAS + (8*8)] %asi, %i0 - htog(0xf2dba847), // ldxa [%sp + BIAS + (9*8)] %asi, %i1 - htog(0xf4dba84f), // ldxa [%sp + BIAS + (10*8)] %asi, %i2 - htog(0xf6dba857), // ldxa [%sp + BIAS + (11*8)] %asi, %i3 - htog(0xf8dba85f), // ldxa [%sp + BIAS + (12*8)] %asi, %i4 - htog(0xfadba867), // ldxa [%sp + BIAS + (13*8)] %asi, %i5 - htog(0xfcdba86f), // ldxa [%sp + BIAS + (14*8)] %asi, %i6 - htog(0xfedba877), // ldxa [%sp + BIAS + (15*8)] %asi, %i7 - htog(0x83880000), // restored - htog(0x83F00000), // retry - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000) // illtrap + htobe(0x87802016), // wr %g0, ASI_AIUP, %asi + htobe(0xe0dba7ff), // ldxa [%sp + BIAS + (0*8)] %asi, %l0 + htobe(0xe2dba807), // ldxa [%sp + BIAS + (1*8)] %asi, %l1 + htobe(0xe4dba80f), // ldxa [%sp + BIAS + (2*8)] %asi, %l2 + htobe(0xe6dba817), // ldxa [%sp + BIAS + (3*8)] %asi, %l3 + htobe(0xe8dba81f), // ldxa [%sp + BIAS + (4*8)] %asi, %l4 + htobe(0xeadba827), // ldxa [%sp + BIAS + (5*8)] %asi, %l5 + htobe(0xecdba82f), // ldxa [%sp + BIAS + (6*8)] %asi, %l6 + htobe(0xeedba837), // ldxa [%sp + BIAS + (7*8)] %asi, %l7 + htobe(0xf0dba83f), // ldxa [%sp + BIAS + (8*8)] %asi, %i0 + htobe(0xf2dba847), // ldxa [%sp + BIAS + (9*8)] %asi, %i1 + htobe(0xf4dba84f), // ldxa [%sp + BIAS + (10*8)] %asi, %i2 + htobe(0xf6dba857), // ldxa [%sp + BIAS + (11*8)] %asi, %i3 + htobe(0xf8dba85f), // ldxa [%sp + BIAS + (12*8)] %asi, %i4 + htobe(0xfadba867), // ldxa [%sp + BIAS + (13*8)] %asi, %i5 + htobe(0xfcdba86f), // ldxa [%sp + BIAS + (14*8)] %asi, %i6 + htobe(0xfedba877), // ldxa [%sp + BIAS + (15*8)] %asi, %i7 + htobe(0x83880000), // restored + htobe(0x83F00000), // retry + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000) // illtrap }; const MachInst fillHandler32[numFillInsts] = { - htog(0x87802016), // wr %g0, ASI_AIUP, %asi - htog(0xe083a000), // lduwa [%sp + (0*4)] %asi, %l0 - htog(0xe283a004), // lduwa [%sp + (1*4)] %asi, %l1 - htog(0xe483a008), // lduwa [%sp + (2*4)] %asi, %l2 - htog(0xe683a00c), // lduwa [%sp + (3*4)] %asi, %l3 - htog(0xe883a010), // lduwa [%sp + (4*4)] %asi, %l4 - htog(0xea83a014), // lduwa [%sp + (5*4)] %asi, %l5 - htog(0xec83a018), // lduwa [%sp + (6*4)] %asi, %l6 - htog(0xee83a01c), // lduwa [%sp + (7*4)] %asi, %l7 - htog(0xf083a020), // lduwa [%sp + (8*4)] %asi, %i0 - htog(0xf283a024), // lduwa [%sp + (9*4)] %asi, %i1 - htog(0xf483a028), // lduwa [%sp + (10*4)] %asi, %i2 - htog(0xf683a02c), // lduwa [%sp + (11*4)] %asi, %i3 - htog(0xf883a030), // lduwa [%sp + (12*4)] %asi, %i4 - htog(0xfa83a034), // lduwa [%sp + (13*4)] %asi, %i5 - htog(0xfc83a038), // lduwa [%sp + (14*4)] %asi, %i6 - htog(0xfe83a03c), // lduwa [%sp + (15*4)] %asi, %i7 - htog(0x83880000), // restored - htog(0x83F00000), // retry - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000) // illtrap + htobe(0x87802016), // wr %g0, ASI_AIUP, %asi + htobe(0xe083a000), // lduwa [%sp + (0*4)] %asi, %l0 + htobe(0xe283a004), // lduwa [%sp + (1*4)] %asi, %l1 + htobe(0xe483a008), // lduwa [%sp + (2*4)] %asi, %l2 + htobe(0xe683a00c), // lduwa [%sp + (3*4)] %asi, %l3 + htobe(0xe883a010), // lduwa [%sp + (4*4)] %asi, %l4 + htobe(0xea83a014), // lduwa [%sp + (5*4)] %asi, %l5 + htobe(0xec83a018), // lduwa [%sp + (6*4)] %asi, %l6 + htobe(0xee83a01c), // lduwa [%sp + (7*4)] %asi, %l7 + htobe(0xf083a020), // lduwa [%sp + (8*4)] %asi, %i0 + htobe(0xf283a024), // lduwa [%sp + (9*4)] %asi, %i1 + htobe(0xf483a028), // lduwa [%sp + (10*4)] %asi, %i2 + htobe(0xf683a02c), // lduwa [%sp + (11*4)] %asi, %i3 + htobe(0xf883a030), // lduwa [%sp + (12*4)] %asi, %i4 + htobe(0xfa83a034), // lduwa [%sp + (13*4)] %asi, %i5 + htobe(0xfc83a038), // lduwa [%sp + (14*4)] %asi, %i6 + htobe(0xfe83a03c), // lduwa [%sp + (15*4)] %asi, %i7 + htobe(0x83880000), // restored + htobe(0x83F00000), // retry + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000) // illtrap }; const MachInst spillHandler64[numSpillInsts] = { - htog(0x87802016), // wr %g0, ASI_AIUP, %asi - htog(0xe0f3a7ff), // stxa %l0, [%sp + BIAS + (0*8)] %asi - htog(0xe2f3a807), // stxa %l1, [%sp + BIAS + (1*8)] %asi - htog(0xe4f3a80f), // stxa %l2, [%sp + BIAS + (2*8)] %asi - htog(0xe6f3a817), // stxa %l3, [%sp + BIAS + (3*8)] %asi - htog(0xe8f3a81f), // stxa %l4, [%sp + BIAS + (4*8)] %asi - htog(0xeaf3a827), // stxa %l5, [%sp + BIAS + (5*8)] %asi - htog(0xecf3a82f), // stxa %l6, [%sp + BIAS + (6*8)] %asi - htog(0xeef3a837), // stxa %l7, [%sp + BIAS + (7*8)] %asi - htog(0xf0f3a83f), // stxa %i0, [%sp + BIAS + (8*8)] %asi - htog(0xf2f3a847), // stxa %i1, [%sp + BIAS + (9*8)] %asi - htog(0xf4f3a84f), // stxa %i2, [%sp + BIAS + (10*8)] %asi - htog(0xf6f3a857), // stxa %i3, [%sp + BIAS + (11*8)] %asi - htog(0xf8f3a85f), // stxa %i4, [%sp + BIAS + (12*8)] %asi - htog(0xfaf3a867), // stxa %i5, [%sp + BIAS + (13*8)] %asi - htog(0xfcf3a86f), // stxa %i6, [%sp + BIAS + (14*8)] %asi - htog(0xfef3a877), // stxa %i7, [%sp + BIAS + (15*8)] %asi - htog(0x81880000), // saved - htog(0x83F00000), // retry - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000) // illtrap + htobe(0x87802016), // wr %g0, ASI_AIUP, %asi + htobe(0xe0f3a7ff), // stxa %l0, [%sp + BIAS + (0*8)] %asi + htobe(0xe2f3a807), // stxa %l1, [%sp + BIAS + (1*8)] %asi + htobe(0xe4f3a80f), // stxa %l2, [%sp + BIAS + (2*8)] %asi + htobe(0xe6f3a817), // stxa %l3, [%sp + BIAS + (3*8)] %asi + htobe(0xe8f3a81f), // stxa %l4, [%sp + BIAS + (4*8)] %asi + htobe(0xeaf3a827), // stxa %l5, [%sp + BIAS + (5*8)] %asi + htobe(0xecf3a82f), // stxa %l6, [%sp + BIAS + (6*8)] %asi + htobe(0xeef3a837), // stxa %l7, [%sp + BIAS + (7*8)] %asi + htobe(0xf0f3a83f), // stxa %i0, [%sp + BIAS + (8*8)] %asi + htobe(0xf2f3a847), // stxa %i1, [%sp + BIAS + (9*8)] %asi + htobe(0xf4f3a84f), // stxa %i2, [%sp + BIAS + (10*8)] %asi + htobe(0xf6f3a857), // stxa %i3, [%sp + BIAS + (11*8)] %asi + htobe(0xf8f3a85f), // stxa %i4, [%sp + BIAS + (12*8)] %asi + htobe(0xfaf3a867), // stxa %i5, [%sp + BIAS + (13*8)] %asi + htobe(0xfcf3a86f), // stxa %i6, [%sp + BIAS + (14*8)] %asi + htobe(0xfef3a877), // stxa %i7, [%sp + BIAS + (15*8)] %asi + htobe(0x81880000), // saved + htobe(0x83F00000), // retry + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000) // illtrap }; const MachInst spillHandler32[numSpillInsts] = { - htog(0x87802016), // wr %g0, ASI_AIUP, %asi - htog(0xe0a3a000), // stwa %l0, [%sp + (0*4)] %asi - htog(0xe2a3a004), // stwa %l1, [%sp + (1*4)] %asi - htog(0xe4a3a008), // stwa %l2, [%sp + (2*4)] %asi - htog(0xe6a3a00c), // stwa %l3, [%sp + (3*4)] %asi - htog(0xe8a3a010), // stwa %l4, [%sp + (4*4)] %asi - htog(0xeaa3a014), // stwa %l5, [%sp + (5*4)] %asi - htog(0xeca3a018), // stwa %l6, [%sp + (6*4)] %asi - htog(0xeea3a01c), // stwa %l7, [%sp + (7*4)] %asi - htog(0xf0a3a020), // stwa %i0, [%sp + (8*4)] %asi - htog(0xf2a3a024), // stwa %i1, [%sp + (9*4)] %asi - htog(0xf4a3a028), // stwa %i2, [%sp + (10*4)] %asi - htog(0xf6a3a02c), // stwa %i3, [%sp + (11*4)] %asi - htog(0xf8a3a030), // stwa %i4, [%sp + (12*4)] %asi - htog(0xfaa3a034), // stwa %i5, [%sp + (13*4)] %asi - htog(0xfca3a038), // stwa %i6, [%sp + (14*4)] %asi - htog(0xfea3a03c), // stwa %i7, [%sp + (15*4)] %asi - htog(0x81880000), // saved - htog(0x83F00000), // retry - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000), // illtrap - htog(0x00000000) // illtrap + htobe(0x87802016), // wr %g0, ASI_AIUP, %asi + htobe(0xe0a3a000), // stwa %l0, [%sp + (0*4)] %asi + htobe(0xe2a3a004), // stwa %l1, [%sp + (1*4)] %asi + htobe(0xe4a3a008), // stwa %l2, [%sp + (2*4)] %asi + htobe(0xe6a3a00c), // stwa %l3, [%sp + (3*4)] %asi + htobe(0xe8a3a010), // stwa %l4, [%sp + (4*4)] %asi + htobe(0xeaa3a014), // stwa %l5, [%sp + (5*4)] %asi + htobe(0xeca3a018), // stwa %l6, [%sp + (6*4)] %asi + htobe(0xeea3a01c), // stwa %l7, [%sp + (7*4)] %asi + htobe(0xf0a3a020), // stwa %i0, [%sp + (8*4)] %asi + htobe(0xf2a3a024), // stwa %i1, [%sp + (9*4)] %asi + htobe(0xf4a3a028), // stwa %i2, [%sp + (10*4)] %asi + htobe(0xf6a3a02c), // stwa %i3, [%sp + (11*4)] %asi + htobe(0xf8a3a030), // stwa %i4, [%sp + (12*4)] %asi + htobe(0xfaa3a034), // stwa %i5, [%sp + (13*4)] %asi + htobe(0xfca3a038), // stwa %i6, [%sp + (14*4)] %asi + htobe(0xfea3a03c), // stwa %i7, [%sp + (15*4)] %asi + htobe(0x81880000), // saved + htobe(0x83F00000), // retry + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000), // illtrap + htobe(0x00000000) // illtrap }; } // namespace SparcISA diff --git a/src/arch/sparc/isa/decoder.isa b/src/arch/sparc/isa/decoder.isa index 95868337e..58141edcf 100644 --- a/src/arch/sparc/isa/decoder.isa +++ b/src/arch/sparc/isa/decoder.isa @@ -1434,14 +1434,14 @@ decode OP default Unknown::unknown() } } 0x3C: CasAlt::casa({{ - mem_data = htog(Rs2_uw); + mem_data = htobe(Rs2_uw); Mem_uw = Rd_uw;}}, {{ uint32_t tmp = mem_data; Rd_uw = tmp; }}, MEM_SWAP_COND); 0x3D: Nop::prefetcha(); - 0x3E: CasAlt::casxa({{mem_data = gtoh(Rs2); + 0x3E: CasAlt::casxa({{mem_data = betoh(Rs2); Mem_udw = Rd_udw; }}, {{ Rd_udw = mem_data; }}, MEM_SWAP_COND); } diff --git a/src/arch/sparc/linux/syscalls.cc b/src/arch/sparc/linux/syscalls.cc index 1abe2476c..b08a7e2de 100644 --- a/src/arch/sparc/linux/syscalls.cc +++ b/src/arch/sparc/linux/syscalls.cc @@ -60,7 +60,7 @@ unameFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) SyscallReturn getresuidFunc(SyscallDesc *desc, int num, ThreadContext *tc) { - const uint64_t id = htog(100); + const uint64_t id = htobe(100); int index = 0; auto p = tc->getProcessPtr(); Addr ruid = p->getSyscallArg(tc, index); diff --git a/src/arch/sparc/nativetrace.cc b/src/arch/sparc/nativetrace.cc index 509e3adb9..aea98d1c0 100644 --- a/src/arch/sparc/nativetrace.cc +++ b/src/arch/sparc/nativetrace.cc @@ -64,26 +64,26 @@ Trace::SparcNativeTrace::check(NativeTraceRecord *record) for (int i = 0; i < SparcISA::NumIntArchRegs; i++) { regVal = tc->readIntReg(i); read(&realRegVal, sizeof(realRegVal)); - realRegVal = SparcISA::gtoh(realRegVal); + realRegVal = betoh(realRegVal); checkReg(*(regName++), regVal, realRegVal); } SparcISA::PCState pc = tc->pcState(); // PC read(&realRegVal, sizeof(realRegVal)); - realRegVal = SparcISA::gtoh(realRegVal); + realRegVal = betoh(realRegVal); regVal = pc.npc(); checkReg("pc", regVal, realRegVal); // NPC read(&realRegVal, sizeof(realRegVal)); - realRegVal = SparcISA::gtoh(realRegVal); + realRegVal = betoh(realRegVal); pc.nnpc(); checkReg("npc", regVal, realRegVal); // CCR read(&realRegVal, sizeof(realRegVal)); - realRegVal = SparcISA::gtoh(realRegVal); + realRegVal = betoh(realRegVal); regVal = tc->readIntReg(SparcISA::NumIntArchRegs + 2); checkReg("ccr", regVal, realRegVal); } diff --git a/src/arch/sparc/process.cc b/src/arch/sparc/process.cc index 33ae68975..23a9b004f 100644 --- a/src/arch/sparc/process.cc +++ b/src/arch/sparc/process.cc @@ -354,7 +354,7 @@ SparcProcess::argsInit(int pageSize) // figure out argc IntType argc = argv.size(); - IntType guestArgc = SparcISA::htog(argc); + IntType guestArgc = htobe(argc); // Write out the sentry void * uint64_t sentry_NULL = 0; @@ -446,7 +446,7 @@ void Sparc32Process::flushWindows(ThreadContext *tc) RegVal sp = tc->readIntReg(StackPointerReg); for (int index = 16; index < 32; index++) { uint32_t regVal = tc->readIntReg(index); - regVal = htog(regVal); + regVal = htobe(regVal); if (!tc->getVirtProxy().tryWriteBlob( sp + (index - 16) * 4, (uint8_t *)®Val, 4)) { warn("Failed to save register to the stack when " @@ -481,7 +481,7 @@ Sparc64Process::flushWindows(ThreadContext *tc) RegVal sp = tc->readIntReg(StackPointerReg); for (int index = 16; index < 32; index++) { RegVal regVal = tc->readIntReg(index); - regVal = htog(regVal); + regVal = htobe(regVal); if (!tc->getVirtProxy().tryWriteBlob( sp + 2047 + (index - 16) * 8, (uint8_t *)®Val, 8)) { warn("Failed to save register to the stack when "