#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;
/// }
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);
// 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.
}
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,