[llvm] r201968 - ARM IAS: support .short and .hword

Saleem Abdulrasool compnerd at compnerd.org
Sat Feb 22 22:22:10 PST 2014


Author: compnerd
Date: Sun Feb 23 00:22:09 2014
New Revision: 201968

URL: http://llvm.org/viewvc/llvm-project?rev=201968&view=rev
Log:
ARM IAS: support .short and .hword

This adds support for the .short and its alias .hword for adding literal values
into the object file.  This is similar to the .word directive, however, rather
than inserting a value of 4 bytes, adds a 2-byte value.

Added:
    llvm/trunk/test/MC/ARM/directive-literals.s
Removed:
    llvm/trunk/test/MC/ARM/arm_word_directive.s
Modified:
    llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp

Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=201968&r1=201967&r2=201968&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Sun Feb 23 00:22:09 2014
@@ -199,7 +199,7 @@ class ARMAsmParser : public MCTargetAsmP
   bool parsePrefix(ARMMCExpr::VariantKind &RefKind);
   bool parseMemRegOffsetShift(ARM_AM::ShiftOpc &ShiftType,
                               unsigned &ShiftAmount);
-  bool parseDirectiveWord(unsigned Size, SMLoc L);
+  bool parseLiteralValues(unsigned Size, SMLoc L);
   bool parseDirectiveThumb(SMLoc L);
   bool parseDirectiveARM(SMLoc L);
   bool parseDirectiveThumbFunc(SMLoc L);
@@ -7959,7 +7959,9 @@ MatchAndEmitInstruction(SMLoc IDLoc, uns
 bool ARMAsmParser::ParseDirective(AsmToken DirectiveID) {
   StringRef IDVal = DirectiveID.getIdentifier();
   if (IDVal == ".word")
-    return parseDirectiveWord(4, DirectiveID.getLoc());
+    return parseLiteralValues(4, DirectiveID.getLoc());
+  else if (IDVal == ".short" || IDVal == ".hword")
+    return parseLiteralValues(2, DirectiveID.getLoc());
   else if (IDVal == ".thumb")
     return parseDirectiveThumb(DirectiveID.getLoc());
   else if (IDVal == ".arm")
@@ -8023,9 +8025,11 @@ bool ARMAsmParser::ParseDirective(AsmTok
   return true;
 }
 
-/// parseDirectiveWord
-///  ::= .word [ expression (, expression)* ]
-bool ARMAsmParser::parseDirectiveWord(unsigned Size, SMLoc L) {
+/// parseLiteralValues
+///  ::= .hword expression [, expression]*
+///  ::= .short expression [, expression]*
+///  ::= .word expression [, expression]*
+bool ARMAsmParser::parseLiteralValues(unsigned Size, SMLoc L) {
   if (getLexer().isNot(AsmToken::EndOfStatement)) {
     for (;;) {
       const MCExpr *Value;

Removed: llvm/trunk/test/MC/ARM/arm_word_directive.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/arm_word_directive.s?rev=201967&view=auto
==============================================================================
--- llvm/trunk/test/MC/ARM/arm_word_directive.s (original)
+++ llvm/trunk/test/MC/ARM/arm_word_directive.s (removed)
@@ -1,6 +0,0 @@
-@ RUN: llvm-mc -mcpu=cortex-a8 -triple arm-unknown-unknown %s | FileCheck %s
-
-@ CHECK: TEST0:
-@ CHECK: .long 3
-TEST0:  
-        .word 3

Added: llvm/trunk/test/MC/ARM/directive-literals.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/directive-literals.s?rev=201968&view=auto
==============================================================================
--- llvm/trunk/test/MC/ARM/directive-literals.s (added)
+++ llvm/trunk/test/MC/ARM/directive-literals.s Sun Feb 23 00:22:09 2014
@@ -0,0 +1,26 @@
+@ RUN: llvm-mc -triple arm %s | FileCheck %s
+
+	.data
+
+short:
+	.short 0
+	.short 0xdefe
+
+@ CHECK-LABEL: short
+@ CHECK-NEXT:	.short 0
+@ CHECK-NEXT:	.short 57086
+
+hword:
+	.hword 0
+	.hword 0xdefe
+
+@ CHECK-LABEL: hword
+@ CHECK-NEXT:	.short 0
+@ CHECK-NEXT:	.short 57086
+
+word:
+	.word 3
+
+@ CHECK-LABEL: word
+@ CHECK-NEXT:	.long 3
+





More information about the llvm-commits mailing list