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;
MCB.setOpcode(Hexagon::BUNDLE);
setAvailableFeatures(ComputeAvailableFeatures(getSTI().getFeatureBits()));
+ Parser.addAliasForDirective(".half", ".2byte");
+ Parser.addAliasForDirective(".hword", ".2byte");
+ Parser.addAliasForDirective(".word", ".4byte");
+
MCAsmParserExtension::Initialize(_Parser);
}
/// 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"))
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<MCConstantExpr>(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
--- /dev/null
+# 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