[PATCH] ARM IAS: support .inst directive

Saleem Abdulrasool compnerd at compnerd.org
Sun Dec 15 14:24:56 PST 2013



================
Comment at: lib/Target/ARM/AsmParser/ARMAsmParser.cpp:8330-8337
@@ +8329,10 @@
+      switch (Width) {
+      case 2:
+        if (Value->getValue() > 0xffff)
+          return Error(Loc, "inst.n operand is too big, use inst.w instead");
+        break;
+      case 4:
+        if (Value->getValue() > 0xffffffff)
+          Warning(Loc, "value 0x" + utohexstr(Value->getValue()) + " truncated");
+        break;
+      default:
----------------
Tim Northover wrote:
> It seems a little odd that "size == 2" always produces an error but "size == 4" a warning.
I modelled the behaviour against GAS.  I would argue that relying on the truncation to be a warning is bad form, and have made this an error as well.  While at it, introduced an additional negative test.

================
Comment at: lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp:196
@@ -192,1 +195,3 @@
 
+void ARMTargetAsmStreamer::emitInst(uint32_t Inst, unsigned Size, char Suffix) {
+  OS << "\t.inst";
----------------
Tim Northover wrote:
> Size is unused in this function.
Inlined the size selection.

================
Comment at: lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp:393-394
@@ +392,4 @@
+       for (unsigned II = 0, IE = Size; II != IE; II = II + 2) {
+         const unsigned I0 = LittleEndian ? II + 0 : (Size - II - 1);
+         const unsigned I1 = LittleEndian ? II + 1 : (Size - II - 2);
+         Buffer[Size - II - 2] = uint8_t(Inst >> I0 * CHAR_BIT);
----------------
Tim Northover wrote:
> I believe instructions are always stored in little-endian format on ARM (well, approximately, it seems to be configurable in R-class processors to avoid annoying people with brain-dead legacy code: see A3.3.1).
> 
> If so, this logic is probably unnecessary.
Unfortunately, for compatibility with GAS, we need to do this stupid swapping :-(.

================
Comment at: lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp:399
@@ +398,3 @@
+     } else {
+       assert(Size == 4 && "Size must be even");
+       EmitARMMappingSymbol();
----------------
Tim Northover wrote:
> I'm reasonably sure there are more even numbers than 4.
Bad message; fixed :-).


http://llvm-reviews.chandlerc.com/D2411



More information about the llvm-commits mailing list