[clang] [llvm] [Hexagon] ELF attributes for Hexagon (PR #85359)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 18 16:34:59 PDT 2024
================
@@ -652,6 +660,57 @@ bool HexagonAsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
return finishBundle(IDLoc, Out);
return false;
}
+/// parseDirectiveAttribute
+/// ::= .attribute int, int
+/// ::= .attribute Tag_name, int
+bool HexagonAsmParser::parseDirectiveAttribute(SMLoc L) {
+ MCAsmParser &Parser = getParser();
+ int64_t Tag;
+ SMLoc TagLoc = Parser.getTok().getLoc();
+ if (Parser.getTok().is(AsmToken::Identifier)) {
+ StringRef Name = Parser.getTok().getIdentifier();
+ std::optional<unsigned> Ret = ELFAttrs::attrTypeFromString(
+ Name, HexagonAttrs::getHexagonAttributeTags());
+ if (!Ret)
+ return Error(TagLoc, "attribute name not recognized: " + Name);
+ Tag = *Ret;
+ Parser.Lex();
+ } else {
+ const MCExpr *AttrExpr;
+
+ TagLoc = Parser.getTok().getLoc();
+ if (Parser.parseExpression(AttrExpr))
+ return true;
+
+ const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(AttrExpr);
+ if (check(!CE, TagLoc, "expected numeric constant"))
+ return true;
+
+ Tag = CE->getValue();
+ }
+
+ if (Parser.parseComma())
+ return true;
+
+ // We currently only have integer values.
+ int64_t IntegerValue = 0;
+ SMLoc ValueExprLoc = Parser.getTok().getLoc();
+ const MCExpr *ValueExpr;
+ if (Parser.parseExpression(ValueExpr))
+ return true;
+
+ const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(ValueExpr);
+ if (!CE)
+ return Error(ValueExprLoc, "expected numeric constant");
+ IntegerValue = CE->getValue();
+
+ if (Parser.parseEOL())
+ return true;
+
+ getTargetStreamer().emitAttribute(Tag, IntegerValue);
+
----------------
quic-areg wrote:
Removed
https://github.com/llvm/llvm-project/pull/85359
More information about the cfe-commits
mailing list