Index: include/llvm/MC/MCSubtargetInfo.h =================================================================== --- include/llvm/MC/MCSubtargetInfo.h +++ include/llvm/MC/MCSubtargetInfo.h @@ -38,6 +38,9 @@ const MCReadAdvanceEntry *ReadAdvanceTable; const MCSchedModel *CPUSchedModel; + // Members of this table have immature MC support + const char **MCImmaturityTable; + const InstrStage *Stages; // Instruction itinerary stages const unsigned *OperandCycles; // Itinerary operand cycles const unsigned *ForwardingPaths; // Forwarding paths @@ -45,6 +48,8 @@ unsigned NumProcs; // Number of processors uint64_t FeatureBits; // Feature bits for current CPU + FS + bool HasMatureMCSupport; // MC Support is mature + public: void InitMCSubtargetInfo(StringRef TT, StringRef CPU, StringRef FS, const SubtargetFeatureKV *PF, @@ -68,6 +73,14 @@ return FeatureBits; } + /// hasMatureMCSupport - Return true if the MC support is considered to be + /// mature. MC support is mature when 'llc -filetype=obj' failing to handle + /// a piece of assembly (inline or otherwise) is considered a bug. + bool hasMatureMCSupport() const { return HasMatureMCSupport; } + + // Determine MC layer maturity by target triple + bool getMCMaturity(StringRef TT) const; + /// InitMCProcessorInfo - Set or change the CPU (optionally supplemented with /// feature string). Recompute feature bits and scheduling model. void InitMCProcessorInfo(StringRef CPU, StringRef FS); Index: lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp =================================================================== --- lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp +++ lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp @@ -79,10 +79,11 @@ if (isNullTerminated) Str = Str.substr(0, Str.size()-1); - // If the output streamer is actually a .s file, just emit the blob textually. + // If the output streamer does not have mature MC support, just emit the blob + // textually. Otherwise parse the asm and emit it via MC support. // This is useful in case the asm parser doesn't handle something but the // system assembler does. - if (OutStreamer.hasRawTextSupport()) { + if (!TM.getSubtarget().hasMatureMCSupport()) { OutStreamer.EmitRawText(Str); emitInlineAsmEnd(TM.getSubtarget(), 0); return; Index: lib/MC/MCSubtargetInfo.cpp =================================================================== --- lib/MC/MCSubtargetInfo.cpp +++ lib/MC/MCSubtargetInfo.cpp @@ -64,6 +64,8 @@ NumFeatures = NF; NumProcs = NP; + HasMatureMCSupport = getMCMaturity(TT); + InitMCProcessorInfo(CPU, FS); } @@ -119,3 +121,27 @@ InstrItins = InstrItineraryData(CPUSchedModel, Stages, OperandCycles, ForwardingPaths); } + +bool MCSubtargetInfo::getMCMaturity(StringRef TT) const { + // FIXME: There must be a better way than this + if (TT.startswith("aarch64-") || + TT.startswith("arm-") || + TT.startswith("armv") || + TT.startswith("xscale-") || + TT.startswith("i386-") || + TT.startswith("i486-") || + TT.startswith("i586-") || + TT.startswith("i686-") || + TT.startswith("i786-") || + TT.startswith("i886-") || + TT.startswith("i986-") || + TT.startswith("amd64-") || + TT.startswith("x86_64-") || + TT.startswith("thumb-") || + TT.startswith("thumbv")) + return true; + + // Assume the MC layer is mature. + return false; +} + Index: test/CodeGen/Generic/mature-mc-support.ll =================================================================== --- /dev/null +++ test/CodeGen/Generic/mature-mc-support.ll @@ -0,0 +1,16 @@ +; Test that inline assembly is parsed by the MC layer when MC support is mature. + +; RUN: not llc -march=aarch64 < %s 2>&1 | FileCheck %s +; RUN: not llc -march=aarch64 -filetype=obj < %s 2>&1 | FileCheck %s +; RUN: not llc -march=arm < %s 2>&1 | FileCheck %s +; RUN: not llc -march=arm -filetype=obj < %s 2>&1 | FileCheck %s +; RUN: not llc -march=thumb < %s 2>&1 | FileCheck %s +; RUN: not llc -march=thumb -filetype=obj < %s 2>&1 | FileCheck %s +; RUN: not llc -march=x86 < %s 2>&1 | FileCheck %s +; RUN: not llc -march=x86 -filetype=obj < %s 2>&1 | FileCheck %s +; RUN: not llc -march=x86-64 < %s 2>&1 | FileCheck %s +; RUN: not llc -march=x86-64 -filetype=obj < %s 2>&1 | FileCheck %s + +module asm " .this_directive_is_very_unlikely_to_exist" + +; CHECK: LLVM ERROR: Error parsing inline asm