45 #define GET_INSTRINFO_MC_DESC 46 #include "HexagonGenInstrInfo.inc" 48 #define GET_SUBTARGETINFO_MC_DESC 49 #include "HexagonGenSubtargetInfo.inc" 51 #define GET_REGINFO_MC_DESC 52 #include "HexagonGenRegisterInfo.inc" 56 cl::desc(
"Disable looking for compound instructions for Hexagon"));
60 cl::desc(
"Disable looking for duplex instructions for Hexagon"));
78 cl::desc(
"Enable Hexagon Vector eXtensions"),
92 cl::desc(
"Disable Hexagon Vector eXtensions"));
148 InstPrinter.
printInst(&Inst, Address,
"", STI, TempStream);
151 auto PacketBundle = Contents.
rsplit(
'\n');
152 auto HeadTail = PacketBundle.first.split(
'\n');
156 while (!HeadTail.first.empty()) {
158 auto Duplex = HeadTail.first.
split(
'\v');
159 if (!Duplex.second.empty()) {
160 OS << Indent << Duplex.first << Separator;
161 InstTxt = Duplex.second;
162 }
else if (!HeadTail.first.trim().startswith(
"immext")) {
163 InstTxt = Duplex.first;
165 if (!InstTxt.
empty())
166 OS << Indent << InstTxt << Separator;
167 HeadTail = HeadTail.second.
split(
'\n');
171 OS <<
"\n\t} :mem_noshuf" << PacketBundle.second;
173 OS <<
"\t}" << PacketBundle.second;
191 unsigned AccessSize)
override {
198 void EmitLocalCommonSymbolSorted(
MCSymbol *Symbol, uint64_t Size,
199 unsigned ByteAlignment,
200 unsigned AccessSize)
override {
204 Symbol, Size, ByteAlignment, AccessSize);
212 InitHexagonMCInstrInfo(X);
218 InitHexagonMCRegisterInfo(X, Hexagon::R31);
237 unsigned SyntaxVariant,
242 if (SyntaxVariant == 0)
251 return new HexagonTargetAsmStreamer(S, OS, IsVerboseAsm, *IP);
255 std::unique_ptr<MCAsmBackend> &&MAB,
256 std::unique_ptr<MCObjectWriter> &&OW,
257 std::unique_ptr<MCCodeEmitter> &&Emitter,
265 return new HexagonTargetELFStreamer(S, STI);
301 .Case(
"hexagonv60",
"+hvxv60")
302 .Case(
"hexagonv62",
"+hvxv62")
303 .Case(
"hexagonv65",
"+hvxv65")
304 .Case(
"hexagonv66",
"+hvxv66"));
317 std::vector<std::string> table {
318 "generic",
"hexagonv5",
"hexagonv55",
"hexagonv60",
319 "hexagonv62",
"hexagonv65",
"hexagonv66",
322 return std::find(table.begin(), table.end(), CPU) != table.end();
326 std::pair<std::string, std::string> selectCPUAndFS(
StringRef CPU,
328 std::pair<std::string, std::string> Result;
330 Result.second = selectHexagonFS(Result.first, FS);
336 using namespace Hexagon;
340 unsigned CpuArch = ArchV5;
341 for (
unsigned F : {ArchV66, ArchV65, ArchV62, ArchV60, ArchV55, ArchV5}) {
348 for (
unsigned F : {ExtensionHVX, ExtensionHVX64B, ExtensionHVX128B}) {
354 bool HasHvxVer =
false;
355 for (
unsigned F : {ExtensionHVXV60, ExtensionHVXV62, ExtensionHVXV65,
364 if (!UseHvx || HasHvxVer)
370 FB.
set(ExtensionHVXV66);
373 FB.
set(ExtensionHVXV65);
376 FB.
set(ExtensionHVXV62);
379 FB.
set(ExtensionHVXV60);
388 std::pair<std::string, std::string> Features = selectCPUAndFS(CPU, FS);
393 errs() <<
"error: invalid CPU \"" << CPUName.
str().c_str()
409 static std::map<StringRef,unsigned> ElfFlags = {
418 auto F = ElfFlags.find(STI.
getCPU());
419 assert(
F != ElfFlags.end() &&
"Unrecognized Architecture");
433 bool isConditionalBranch(
MCInst const &Inst)
const override {
438 bool evaluateBranch(
MCInst const &Inst, uint64_t Addr,
439 uint64_t
Size, uint64_t &
Target)
const override {
444 assert(Extended.isExpr());
446 if(!Extended.getExpr()->evaluateAsAbsolute(Value))
455 return new HexagonMCInstrAnalysis(Info);
void setELFHeaderEFlags(unsigned Flags)
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
void setFeatureBits(const FeatureBitset &FeatureBits_)
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
static void RegisterMCInstrAnalysis(Target &T, Target::MCInstrAnalysisCtorFnTy Fn)
RegisterMCInstrAnalysis - Register a MCInstrAnalysis implementation for the given target...
void push_back(const T &Elt)
Target specific streamer interface.
virtual bool isConditionalBranch(const MCInst &Inst) const
bool isBundle(MCInst const &MCI)
unsigned HexagonGetLastSlot()
LLVM_NODISCARD std::pair< StringRef, StringRef > rsplit(StringRef Separator) const
Split into two substrings around the last occurrence of a separator string.
static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn)
RegisterMCInstPrinter - Register a MCInstPrinter implementation for the given target.
static void RegisterAsmTargetStreamer(Target &T, Target::AsmTargetStreamerCtorTy Fn)
static MCAsmInfo * createHexagonMCAsmInfo(const MCRegisterInfo &MRI, const Triple &TT, const MCTargetOptions &Options)
MCCodeEmitter * createHexagonMCCodeEmitter(const MCInstrInfo &MCII, const MCRegisterInfo &MRI, MCContext &MCT)
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeHexagonTargetMC()
const FeatureBitset & getFeatureBits() const
MCAsmBackend * createHexagonAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options)
MCOperand const & getExtendableOperand(MCInstrInfo const &MCII, MCInst const &MCI)
std::string join(IteratorT Begin, IteratorT End, StringRef Separator)
Joins the strings in the range [Begin, End), adding Separator between the elements.
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Context object for machine code objects.
virtual bool isUnconditionalBranch(const MCInst &Inst) const
int getDwarfRegNum(MCRegister RegNum, bool isEH) const
Map a target register to an equivalent dwarf register number.
constexpr bool test(unsigned I) const
static MCInstrAnalysis * createHexagonMCInstrAnalysis(const MCInstrInfo *Info)
static StringRef DefaultArch
static bool isUnconditionalBranch(Instruction *Term)
MCInstrInfo * createHexagonMCInstrInfo()
static MCStreamer * createMCStreamer(Triple const &T, MCContext &Context, std::unique_ptr< MCAsmBackend > &&MAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter, bool RelaxAll)
Analysis containing CSE Info
Instances of this class represent a single low-level machine instruction.
StringRef selectHexagonCPU(StringRef CPU)
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
This class is intended to be used as a base class for asm properties and features specific to the tar...
FeatureBitset ToggleFeature(uint64_t FB)
Toggle a feature and return the re-computed feature bits.
static void RegisterMCAsmBackend(Target &T, Target::MCAsmBackendCtorTy Fn)
RegisterMCAsmBackend - Register a MCAsmBackend implementation for the given target.
A switch()-like statement whose cases are string literals.
initializer< Ty > init(const Ty &Val)
Streaming machine code generation interface.
unsigned const MachineRegisterInfo * MRI
Container class for subtarget features.
static MCCFIInstruction createDefCfa(MCSymbol *L, unsigned Register, int Offset)
.cfi_def_cfa defines a rule for computing CFA as: take address from Register and add Offset to it...
static MCInstPrinter * createHexagonMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
static cl::opt< bool > DisableHVX("mno-hvx", cl::Hidden, cl::desc("Disable Hexagon Vector eXtensions"))
FeatureBitset completeHVXFeatures(const FeatureBitset &FB)
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
Interface to description of machine instruction set.
cl::opt< bool > HexagonDisableCompound
MCSubtargetInfo * createHexagonMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS)
Create a Hexagon MCSubtargetInfo instance.
#define LLVM_ATTRIBUTE_UNUSED
static MCTargetStreamer * createMCAsmTargetStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *IP, bool IsVerboseAsm)
static void LLVM_ATTRIBUTE_UNUSED clearFeature(MCSubtargetInfo *STI, uint64_t F)
static MCTargetStreamer * createHexagonObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
static void RegisterMCSubtargetInfo(Target &T, Target::MCSubtargetInfoCtorFnTy Fn)
RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for the given target...
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
static void RegisterObjectTargetStreamer(Target &T, Target::ObjectTargetStreamerCtorTy Fn)
unsigned GetELFFlags(const MCSubtargetInfo &STI)
Triple - Helper class for working with autoconf configuration names.
Prints bundles as a newline separated list of individual instructions Duplexes are separated by a ver...
void HexagonMCEmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment, unsigned AccessSize)
static bool isCPUValid(std::string CPU)
void addInitialFrameState(const MCCFIInstruction &Inst)
bool isExtendable(MCInstrInfo const &MCII, MCInst const &MCI)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
static void RegisterMCCodeEmitter(Target &T, Target::MCCodeEmitterCtorTy Fn)
RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the given target.
#define LLVM_EXTERNAL_VISIBILITY
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn)
RegisterMCRegInfo - Register a MCRegisterInfo implementation for the given target.
Target - Wrapper for Target specific information.
bool isMemReorderDisabled(MCInst const &MCI)
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
static StringRef HexagonGetArchVariant()
virtual void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, const MCSubtargetInfo &STI, raw_ostream &OS)=0
Print the specified MCInst to the specified raw_ostream.
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
constexpr FeatureBitset & reset(unsigned I)
static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn)
RegisterMCInstrInfo - Register a MCInstrInfo implementation for the given target. ...
Generic base class for all target subtargets.
size_t bundleSize(MCInst const &MCI)
static void RegisterELFStreamer(Target &T, Target::ELFStreamerCtorTy Fn)
static bool LLVM_ATTRIBUTE_UNUSED checkFeature(MCSubtargetInfo *STI, uint64_t F)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MCStreamer * createHexagonELFStreamer(Triple const &TT, MCContext &Context, std::unique_ptr< MCAsmBackend > MAB, std::unique_ptr< MCObjectWriter > OW, std::unique_ptr< MCCodeEmitter > CE)
A raw_ostream that writes to an std::string.
#define HEXAGON_PACKET_SIZE
RegisterMCAsmInfoFn - Helper template for registering a target assembly info implementation.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.
MCRegisterInfo * createHexagonMCRegisterInfo(StringRef TT)
Target & getTheHexagonTarget()
cl::opt< bool > HexagonDisableDuplex
void HexagonMCEmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment, unsigned AccessSize)