[llvm] r252989 - [Hexagon] Adding relaxation functionality to backend and test.
Colin LeMahieu via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 12 17:12:26 PST 2015
Author: colinl
Date: Thu Nov 12 19:12:25 2015
New Revision: 252989
URL: http://llvm.org/viewvc/llvm-project?rev=252989&view=rev
Log:
[Hexagon] Adding relaxation functionality to backend and test.
Added:
llvm/trunk/test/MC/Hexagon/jumpdoublepound.s
llvm/trunk/test/MC/Hexagon/two_ext.s
Modified:
llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp
Modified: llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp?rev=252989&r1=252988&r2=252989&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp Thu Nov 12 19:12:25 2015
@@ -276,9 +276,37 @@ public:
llvm_unreachable("Handled by fixupNeedsRelaxationAdvanced");
}
- void relaxInstruction(MCInst const & /*Inst*/,
- MCInst & /*Res*/) const override {
- llvm_unreachable("relaxInstruction() unimplemented");
+ void relaxInstruction(MCInst const & Inst,
+ MCInst & Res) const override {
+ assert(HexagonMCInstrInfo::isBundle(Inst) &&
+ "Hexagon relaxInstruction only works on bundles");
+
+ Res.setOpcode(Hexagon::BUNDLE);
+ Res.addOperand(MCOperand::createImm(0));
+ // Copy the results into the bundle.
+ bool Update = false;
+ for (auto &I : HexagonMCInstrInfo::bundleInstructions(Inst)) {
+ MCInst &CrntHMI = const_cast<MCInst &>(*I.getInst());
+
+ // if immediate extender needed, add it in
+ if (*RelaxTarget == &CrntHMI) {
+ Update = true;
+ assert((HexagonMCInstrInfo::bundleSize(Res) < HEXAGON_PACKET_SIZE) &&
+ "No room to insert extender for relaxation");
+
+ MCInst *HMIx =
+ new MCInst(HexagonMCInstrInfo::deriveExtender(
+ *MCII, CrntHMI,
+ HexagonMCInstrInfo::getExtendableOperand(*MCII, CrntHMI)));
+
+ Res.addOperand(MCOperand::createInst(HMIx));
+ *RelaxTarget = nullptr;
+ }
+ // now copy over the original instruction(the one we may have extended)
+ Res.addOperand(MCOperand::createInst(I.getInst()));
+ }
+ (void)Update;
+ assert(Update && "Didn't find relaxation target");
}
bool writeNopData(uint64_t Count,
Added: llvm/trunk/test/MC/Hexagon/jumpdoublepound.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Hexagon/jumpdoublepound.s?rev=252989&view=auto
==============================================================================
--- llvm/trunk/test/MC/Hexagon/jumpdoublepound.s (added)
+++ llvm/trunk/test/MC/Hexagon/jumpdoublepound.s Thu Nov 12 19:12:25 2015
@@ -0,0 +1,13 @@
+# RUN: llvm-mc -triple=hexagon -filetype=obj %s -o - | llvm-objdump -d - | FileCheck %s
+
+# Verify that jump encodes correctly
+
+
+mylabel:
+# CHECK: if (p0) jump
+if (p0) jump ##mylabel
+
+# CHECK: if (cmp.gtu(r5.new, r4)) jump:t
+{ r5 = r4
+ if (cmp.gtu(r5.new, r4)) jump:t ##mylabel }
+
Added: llvm/trunk/test/MC/Hexagon/two_ext.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Hexagon/two_ext.s?rev=252989&view=auto
==============================================================================
--- llvm/trunk/test/MC/Hexagon/two_ext.s (added)
+++ llvm/trunk/test/MC/Hexagon/two_ext.s Thu Nov 12 19:12:25 2015
@@ -0,0 +1,12 @@
+# RUN: llvm-mc -triple=hexagon -filetype=obj %s | llvm-objdump -d - | FileCheck %s
+
+# verify two extenders generated during relaxation
+{
+ if (p1) call foo_a
+ if (!p1) call foo_b
+}
+# CHECK: 00004000 { immext(#0)
+# CHECK: 5d004100 if (p1) call 0x0
+# CHECK: 00004000 immext(#0)
+# CHECK: 5d20c100 if (!p1) call 0x0 }
+
More information about the llvm-commits
mailing list