Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.

Commit

Permalink
ARM IAS: support .short and .hword
Browse files Browse the repository at this point in the history
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201968 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
compnerd committed Feb 23, 2014
1 parent ea06d97 commit be66089
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 11 deletions.
14 changes: 9 additions & 5 deletions lib/Target/ARM/AsmParser/ARMAsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class ARMAsmParser : public MCTargetAsmParser {
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);
Expand Down Expand Up @@ -7959,7 +7959,9 @@ MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
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")
Expand Down Expand Up @@ -8023,9 +8025,11 @@ bool ARMAsmParser::ParseDirective(AsmToken DirectiveID) {
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;
Expand Down
6 changes: 0 additions & 6 deletions test/MC/ARM/arm_word_directive.s

This file was deleted.

26 changes: 26 additions & 0 deletions test/MC/ARM/directive-literals.s
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit be66089

Please sign in to comment.