diff options
author | Kai Nacke <kai@redstar.de> | 2022-08-05 05:27:37 -0400 |
---|---|---|
committer | Kai Nacke <kai@redstar.de> | 2022-11-13 11:07:40 -0500 |
commit | d65c906938116772e2a1c46dcb7f699694ec8d3d (patch) | |
tree | eb8149460962cb6cadcebff7878d045b05440e85 | |
parent | 25b88a4d3e86d0300caf55867171ae4c35e6ea2c (diff) | |
download | llvm-d65c906938116772e2a1c46dcb7f699694ec8d3d.zip llvm-d65c906938116772e2a1c46dcb7f699694ec8d3d.tar.gz llvm-d65c906938116772e2a1c46dcb7f699694ec8d3d.tar.bz2 |
[m88k] Fix endian bug affecting double constants
The operands of G_MERGE_VALUES and G_UNMERGE_VALUES must be in little
endian order. The CallLowering implementation used big endian order,
resulting in double constant returned as function value being in the wrong
order.
-rw-r--r-- | llvm/lib/Target/M88k/GISel/M88kCallLowering.cpp | 48 | ||||
-rw-r--r-- | llvm/test/CodeGen/M88k/constant.ll | 5 |
2 files changed, 26 insertions, 27 deletions
diff --git a/llvm/lib/Target/M88k/GISel/M88kCallLowering.cpp b/llvm/lib/Target/M88k/GISel/M88kCallLowering.cpp index 6a95327..7b1f17d 100644 --- a/llvm/lib/Target/M88k/GISel/M88kCallLowering.cpp +++ b/llvm/lib/Target/M88k/GISel/M88kCallLowering.cpp @@ -116,22 +116,22 @@ unsigned OutgoingArgHandler::assignCustomValue(CallLowering::ArgInfo &Arg, std::function<void()> *Thunk) { assert(Arg.Regs.size() == 1 && "Can't handle multple regs yet"); - CCValAssign VA = VAs[0]; - assert(VA.needsCustom() && "Value doesn't need custom handling"); + CCValAssign HiVA = VAs[0]; + assert(HiVA.needsCustom() && "Value doesn't need custom handling"); // Custom lowering for other types, such as f16, is currently not supported - if (VA.getValVT() != MVT::f64) + if (HiVA.getValVT() != MVT::f64) return 0; - CCValAssign NextVA = VAs[1]; - assert(NextVA.needsCustom() && "Value doesn't need custom handling"); - assert(NextVA.getValVT() == MVT::f64 && "Unsupported type"); + CCValAssign LoVA = VAs[1]; + assert(LoVA.needsCustom() && "Value doesn't need custom handling"); + assert(LoVA.getValVT() == MVT::f64 && "Unsupported type"); - assert(VA.getValNo() == NextVA.getValNo() && + assert(HiVA.getValNo() == LoVA.getValNo() && "Values belong to different arguments"); - assert(VA.isRegLoc() && "Value should be in reg"); - assert(NextVA.isRegLoc() && "Value should be in reg"); + assert(HiVA.isRegLoc() && "Value should be in reg"); + assert(LoVA.isRegLoc() && "Value should be in reg"); Register NewRegs[] = {MRI.createGenericVirtualRegister(LLT::scalar(32)), MRI.createGenericVirtualRegister(LLT::scalar(32))}; @@ -139,13 +139,13 @@ unsigned OutgoingArgHandler::assignCustomValue(CallLowering::ArgInfo &Arg, if (Thunk) { *Thunk = [=]() { - assignValueToReg(NewRegs[0], VA.getLocReg(), VA); - assignValueToReg(NewRegs[1], NextVA.getLocReg(), NextVA); + assignValueToReg(NewRegs[0], LoVA.getLocReg(), LoVA); + assignValueToReg(NewRegs[1], HiVA.getLocReg(), HiVA); }; return 1; } - assignValueToReg(NewRegs[0], VA.getLocReg(), VA); - assignValueToReg(NewRegs[1], NextVA.getLocReg(), NextVA); + assignValueToReg(NewRegs[0], LoVA.getLocReg(), LoVA); + assignValueToReg(NewRegs[1], HiVA.getLocReg(), HiVA); return 1; } @@ -236,28 +236,28 @@ M88kIncomingValueHandler::assignCustomValue(CallLowering::ArgInfo &Arg, std::function<void()> *Thunk) { assert(Arg.Regs.size() == 1 && "Can't handle multple regs yet"); - CCValAssign VA = VAs[0]; - assert(VA.needsCustom() && "Value doesn't need custom handling"); + CCValAssign HiVA = VAs[0]; + assert(HiVA.needsCustom() && "Value doesn't need custom handling"); // Custom lowering for other types is currently not supported. - if (VA.getValVT() != MVT::f64) + if (HiVA.getValVT() != MVT::f64) return 0; - CCValAssign NextVA = VAs[1]; - assert(NextVA.needsCustom() && "Value doesn't need custom handling"); - assert(NextVA.getValVT() == MVT::f64 && "Unsupported type"); + CCValAssign LoVA = VAs[1]; + assert(LoVA.needsCustom() && "Value doesn't need custom handling"); + assert(LoVA.getValVT() == MVT::f64 && "Unsupported type"); - assert(VA.getValNo() == NextVA.getValNo() && + assert(HiVA.getValNo() == LoVA.getValNo() && "Values belong to different arguments"); - assert(VA.isRegLoc() && "Value should be in reg"); - assert(NextVA.isRegLoc() && "Value should be in reg"); + assert(HiVA.isRegLoc() && "Value should be in reg"); + assert(LoVA.isRegLoc() && "Value should be in reg"); Register NewRegs[] = {MRI.createGenericVirtualRegister(LLT::scalar(32)), MRI.createGenericVirtualRegister(LLT::scalar(32))}; - assignValueToReg(NewRegs[0], VA.getLocReg(), VA); - assignValueToReg(NewRegs[1], NextVA.getLocReg(), NextVA); + assignValueToReg(NewRegs[0], LoVA.getLocReg(), LoVA); + assignValueToReg(NewRegs[1], HiVA.getLocReg(), HiVA); MIRBuilder.buildMerge(Arg.Regs[0], NewRegs); diff --git a/llvm/test/CodeGen/M88k/constant.ll b/llvm/test/CodeGen/M88k/constant.ll index 98a1014..88eedd2 100644 --- a/llvm/test/CodeGen/M88k/constant.ll +++ b/llvm/test/CodeGen/M88k/constant.ll @@ -123,9 +123,8 @@ define float @f15() { define double @f16() { ; CHECK-LABEL: f16: -; Big Endian Bug! -; NOT: CHECK: or %r2, %r0, 0 -; NOT: CHECK: or.u %r3, %r0, 16368 +; CHECK: or %r3, %r0, 0 +; CHECK: or.u %r2, %r0, 16368 ; Alternativ instruction could also be: set %r2,%r0,10<20> ; CHECK: jmp %r1 ret double 1.0 |