Index: llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp =================================================================== --- llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp +++ llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp @@ -118,7 +118,6 @@ bool ParseRegister(unsigned &RegNo, SMLoc &StartLoc, SMLoc &EndLoc) override; bool ParseDirectiveSubsection(SMLoc L); - bool ParseDirectiveValue(unsigned Size, SMLoc L); bool ParseDirectiveComm(bool IsLocal, SMLoc L); bool RegisterMatchesArch(unsigned MatchNum) const; @@ -165,6 +164,10 @@ MCB.setOpcode(Hexagon::BUNDLE); setAvailableFeatures(ComputeAvailableFeatures(getSTI().getFeatureBits())); + Parser.addAliasForDirective(".half", ".2byte"); + Parser.addAliasForDirective(".hword", ".2byte"); + Parser.addAliasForDirective(".word", ".4byte"); + MCAsmParserExtension::Initialize(_Parser); } @@ -651,11 +654,6 @@ /// ParseDirective parses the Hexagon specific directives bool HexagonAsmParser::ParseDirective(AsmToken DirectiveID) { StringRef IDVal = DirectiveID.getIdentifier(); - if ((IDVal.lower() == ".word") || (IDVal.lower() == ".4byte")) - return ParseDirectiveValue(4, DirectiveID.getLoc()); - if (IDVal.lower() == ".short" || IDVal.lower() == ".hword" || - IDVal.lower() == ".half") - return ParseDirectiveValue(2, DirectiveID.getLoc()); if (IDVal.lower() == ".falign") return ParseDirectiveFalign(256, DirectiveID.getLoc()); if ((IDVal.lower() == ".lcomm") || (IDVal.lower() == ".lcommon")) @@ -723,39 +721,6 @@ return false; } -/// ::= .word [ expression (, expression)* ] -bool HexagonAsmParser::ParseDirectiveValue(unsigned Size, SMLoc L) { - if (getLexer().isNot(AsmToken::EndOfStatement)) { - while (true) { - const MCExpr *Value; - SMLoc ExprLoc = L; - if (getParser().parseExpression(Value)) - return true; - - // Special case constant expressions to match code generator. - if (const MCConstantExpr *MCE = dyn_cast(Value)) { - assert(Size <= 8 && "Invalid size"); - uint64_t IntValue = MCE->getValue(); - if (!isUIntN(8 * Size, IntValue) && !isIntN(8 * Size, IntValue)) - return Error(ExprLoc, "literal value out of range for directive"); - getStreamer().EmitIntValue(IntValue, Size); - } else - getStreamer().EmitValue(Value, Size); - - if (getLexer().is(AsmToken::EndOfStatement)) - break; - - // FIXME: Improve diagnostic. - if (getLexer().isNot(AsmToken::Comma)) - return TokError("unexpected token in directive"); - Lex(); - } - } - - Lex(); - return false; -} - // This is largely a copy of AsmParser's ParseDirectiveComm extended to // accept a 3rd argument, AccessAlignment which indicates the smallest // memory access made to the symbol, expressed in bytes. If no Index: llvm/trunk/test/MC/Hexagon/data-directives-invalid.s =================================================================== --- llvm/trunk/test/MC/Hexagon/data-directives-invalid.s +++ llvm/trunk/test/MC/Hexagon/data-directives-invalid.s @@ -0,0 +1,20 @@ +# RUN: not llvm-mc -triple hexagon < %s 2>&1 | FileCheck %s + +# CHECK: [[@LINE+1]]:7: error: out of range literal value in '.byte' directive +.byte 0xffa +# CHECK: [[@LINE+1]]:7: error: out of range literal value in '.half' directive +.half 0xffffa +# CHECK: [[@LINE+1]]:8: error: out of range literal value in '.short' directive +.short 0xffffa +# CHECK: [[@LINE+1]]:8: error: out of range literal value in '.hword' directive +.hword 0xffffa +# CHECK: [[@LINE+1]]:8: error: out of range literal value in '.2byte' directive +.2byte 0xffffa +# CHECK: [[@LINE+1]]:7: error: out of range literal value in '.word' directive +.word 0xffffffffa +# CHECK: [[@LINE+1]]:7: error: out of range literal value in '.long' directive +.long 0xffffffffa +# CHECK: [[@LINE+1]]:8: error: out of range literal value in '.4byte' directive +.4byte 0xffffffffa +# CHECK: [[@LINE+1]]:8: error: literal value out of range for directive in '.8byte' directive +.8byte 0xffffffffffffffffa Index: llvm/trunk/test/MC/Hexagon/data-directives-valid.s =================================================================== --- llvm/trunk/test/MC/Hexagon/data-directives-valid.s +++ llvm/trunk/test/MC/Hexagon/data-directives-valid.s @@ -0,0 +1,25 @@ +# RUN: llvm-mc -filetype=obj -triple hexagon < %s \ +# RUN: | llvm-objdump -s - | FileCheck %s + +.data + +# CHECK: Contents of section .data: +# CHECK-NEXT: 0000 deadbeef badcaf11 22334455 66778800 +.byte 0xde +.half 0xbead +.word 0xafdcbaef +.8byte 0x8877665544332211 +.byte 0 + +# CHECK-NEXT: 0010 deadbeef badcaf11 22334455 66778800 +.byte 0xde +.2byte 0xbead +.4byte 0xafdcbaef +.8byte 0x8877665544332211 +.byte 0 + +# CHECK-NEXT: 0020 deadbeef badcaf11 22 +.byte 0xde +.short 0xbead +.long 0xafdcbaef +.hword 0x2211