#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ELF.h"
+#include "llvm/Support/Format.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/TargetRegistry.h"
return static_cast<HexagonTargetStreamer &>(TS);
}
- MCSubtargetInfo &STI;
MCAsmParser &Parser;
MCAssembler *Assembler;
MCInstrInfo const &MCII;
MCAssembler *getAssembler() const { return Assembler; }
MCAsmLexer &getLexer() const { return Parser.getLexer(); }
- unsigned ArchVersion;
-
bool equalIsAsmAssignment() override { return false; }
bool isLabel(AsmToken &Token) override;
bool MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
OperandVector &Operands, MCStreamer &Out,
- uint64_t &ErrorInfo, bool MatchingInlineAsm);
+ uint64_t &ErrorInfo, bool MatchingInlineAsm) override;
unsigned validateTargetOperandClass(MCParsedAsmOperand &Op, unsigned Kind) override;
void OutOfRange(SMLoc IDLoc, long long Val, long long Max);
/// }
public:
- HexagonAsmParser(MCSubtargetInfo &_STI, MCAsmParser &_Parser,
+ HexagonAsmParser(const MCSubtargetInfo &_STI, MCAsmParser &_Parser,
const MCInstrInfo &MII, const MCTargetOptions &Options)
- : MCTargetAsmParser(Options), STI(_STI), Parser(_Parser),
- MCII (MII), InBrackets(false) {
- MCB.setOpcode(Hexagon::BUNDLE);
- setAvailableFeatures(
- ComputeAvailableFeatures(_STI.getFeatureBits()));
+ : MCTargetAsmParser(Options, _STI), Parser(_Parser),
+ MCII (MII), MCB(HexagonMCInstrInfo::createBundle()), InBrackets(false) {
+ setAvailableFeatures(ComputeAvailableFeatures(getSTI().getFeatureBits()));
MCAsmParserExtension::Initialize(_Parser);
bool parseExpressionOrOperand(OperandVector &Operands);
bool parseExpression(MCExpr const *& Expr);
virtual bool ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
- SMLoc NameLoc, OperandVector &Operands) {
+ SMLoc NameLoc, OperandVector &Operands) override
+ {
llvm_unreachable("Unimplemented");
}
virtual bool ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
- AsmToken ID, OperandVector &Operands);
+ AsmToken ID, OperandVector &Operands) override;
- virtual bool ParseDirective(AsmToken DirectiveID);
+ virtual bool ParseDirective(AsmToken DirectiveID) override;
};
/// HexagonOperand - Instances of this class represent a parsed Hexagon machine
// Check the bundle for errors.
const MCRegisterInfo *RI = getContext().getRegisterInfo();
- HexagonMCChecker Check(MCII, STI, MCB, MCB, *RI);
+ HexagonMCChecker Check(MCII, getSTI(), MCB, MCB, *RI);
- bool CheckOk = HexagonMCInstrInfo::canonicalizePacket(MCII, STI, getContext(),
- MCB, &Check);
+ bool CheckOk = HexagonMCInstrInfo::canonicalizePacket(MCII, getSTI(),
+ getContext(), MCB,
+ &Check);
while (Check.getNextErrInfo() == true) {
unsigned Reg = Check.getErrRegister();
// Empty packets are valid yet aren't emitted
return false;
}
- Out.EmitInstruction(MCB, STI);
+ Out.EmitInstruction(MCB, getSTI());
} else {
// If compounding and duplexing didn't reduce the size below
// 4 or less we have a packet that is too big.
MatchingInlineAsm, MustExtend))
return true;
HexagonMCInstrInfo::extendIfNeeded(
- MCII, MCB, *SubInst,
+ getParser().getContext(), MCII, MCB, *SubInst,
HexagonMCInstrInfo::isExtended(MCII, *SubInst) || MustExtend);
MCB.addOperand(MCOperand::createInst(SubInst));
if (!InBrackets)
return true;
if (!MatchRegisterName(String.lower()))
return true;
+ (void)Second;
assert(Second.is(AsmToken::Colon));
StringRef Raw (String.data(), Third.getString().data() - String.data() +
Third.getString().size());
}
void HexagonAsmParser::OutOfRange(SMLoc IDLoc, long long Val, long long Max) {
- std::stringstream errStr;
- errStr << "value " << Val << "(0x" << std::hex << Val << std::dec
- << ") out of range: ";
+ std::string errStr;
+ raw_string_ostream ES(errStr);
+ ES << "value " << Val << "(" << format_hex(Val, 0) << ") out of range: ";
if (Max >= 0)
- errStr << "0-" << Max;
+ ES << "0-" << Max;
else
- errStr << Max << "-" << (-Max - 1);
- Error(IDLoc, errStr.str().c_str());
+ ES << Max << "-" << (-Max - 1);
+ Error(IDLoc, ES.str().c_str());
}
int HexagonAsmParser::processInstruction(MCInst &Inst,
MCOperand &MO = Inst.getOperand(2);
int64_t Value;
bool Success = MO.getExpr()->evaluateAsAbsolute(Value);
+ (void)Success;
assert(Success && "Assured by matcher");
if (Value == 0) {
MCInst TmpInst;