mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-27 04:18:42 +00:00
Merging r224425:
------------------------------------------------------------------------ r224425 | tomatabacu | 2014-12-17 10:56:16 +0000 (Wed, 17 Dec 2014) | 17 lines [mips] Set GCC-compatible MIPS asssembler options before inline asm blocks. Summary: When generating MIPS assembly, LLVM always overrides the default assembler options by emitting the '.set noreorder', '.set nomacro' and '.set noat' directives, while GCC uses the default options if an assembly-level function contains inline assembly code. This becomes a problem when the code generated by LLVM is interleaved with inline assembly which assumes GCC-like assembler options (from Linux, for example). This patch fixes these conflicts by setting the appropriate assembler options at the beginning of an inline asm block and popping them at the end. Reviewers: dsanders Reviewed By: dsanders Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D6637 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_35@231462 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
1 parent
3682830c9e
commit
89ee039cd4
9 files changed
+64
-31
No files matched your search
@@ -89,6 +89,7 @@ void AsmPrinter::EmitInlineAsm(StringRef Str, const MDNode *LocMDNode,
|
||||
assert(MCAI && "No MCAsmInfo");
|
||||
if (!MCAI->useIntegratedAssembler() &&
|
||||
!OutStreamer.isIntegratedAssemblerRequired()) {
|
||||
emitInlineAsmStart(TM.getSubtarget<MCSubtargetInfo>());
|
||||
OutStreamer.EmitRawText(Str);
|
||||
emitInlineAsmEnd(TM.getSubtarget<MCSubtargetInfo>(), nullptr);
|
||||
return;
|
||||
@@ -147,6 +148,7 @@ void AsmPrinter::EmitInlineAsm(StringRef Str, const MDNode *LocMDNode,
|
||||
Parser->setAssemblerDialect(Dialect);
|
||||
Parser->setTargetParser(*TAP.get());
|
||||
|
||||
emitInlineAsmStart(STIOrig);
|
||||
// Don't implicitly switch to the text section before the asm.
|
||||
int Res = Parser->Run(/*NoInitialTextSection*/ true,
|
||||
/*NoFinalize*/ true);
|
||||
@@ -561,5 +563,7 @@ bool AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
return true;
|
||||
}
|
||||
|
||||
void AsmPrinter::emitInlineAsmStart(const MCSubtargetInfo &StartInfo) const {}
|
||||
|
||||
void AsmPrinter::emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
|
||||
const MCSubtargetInfo *EndInfo) const {}
|
||||
@@ -458,7 +458,6 @@ static void createFPFnStub(Function *F, Module *M, FPParamVariant PV,
|
||||
FStub->setSection(SectionName);
|
||||
BasicBlock *BB = BasicBlock::Create(Context, "entry", FStub);
|
||||
InlineAsmHelper IAH(Context, BB);
|
||||
IAH.Out(" .set macro");
|
||||
if (PicMode) {
|
||||
IAH.Out(".set noreorder");
|
||||
IAH.Out(".cpload $$25");
|
||||
@@ -467,7 +466,6 @@ static void createFPFnStub(Function *F, Module *M, FPParamVariant PV,
|
||||
IAH.Out("la $$25," + LocalName);
|
||||
}
|
||||
else {
|
||||
IAH.Out(".set reorder");
|
||||
IAH.Out("la $$25," + Name);
|
||||
}
|
||||
swapFPIntParams(PV, M, IAH, LE, false);
|
||||
|
||||
@@ -53,7 +53,7 @@ using namespace llvm;
|
||||
|
||||
#define DEBUG_TYPE "mips-asm-printer"
|
||||
|
||||
MipsTargetStreamer &MipsAsmPrinter::getTargetStreamer() {
|
||||
MipsTargetStreamer &MipsAsmPrinter::getTargetStreamer() const {
|
||||
return static_cast<MipsTargetStreamer &>(*OutStreamer.getTargetStreamer());
|
||||
}
|
||||
|
||||
@@ -721,6 +721,23 @@ void MipsAsmPrinter::EmitStartOfAsmFile(Module &M) {
|
||||
Subtarget->isABI_O32());
|
||||
}
|
||||
|
||||
void MipsAsmPrinter::emitInlineAsmStart(
|
||||
const MCSubtargetInfo &StartInfo) const {
|
||||
MipsTargetStreamer &TS = getTargetStreamer();
|
||||
|
||||
TS.emitDirectiveSetPush();
|
||||
TS.emitDirectiveSetAt();
|
||||
TS.emitDirectiveSetMacro();
|
||||
TS.emitDirectiveSetReorder();
|
||||
OutStreamer.AddBlankLine();
|
||||
}
|
||||
|
||||
void MipsAsmPrinter::emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
|
||||
const MCSubtargetInfo *EndInfo) const {
|
||||
OutStreamer.AddBlankLine();
|
||||
getTargetStreamer().emitDirectiveSetPop();
|
||||
}
|
||||
|
||||
void MipsAsmPrinter::EmitJal(MCSymbol *Symbol) {
|
||||
MCInst I;
|
||||
I.setOpcode(Mips::JAL);
|
||||
|
||||
@@ -31,7 +31,7 @@ class Module;
|
||||
class raw_ostream;
|
||||
|
||||
class LLVM_LIBRARY_VISIBILITY MipsAsmPrinter : public AsmPrinter {
|
||||
MipsTargetStreamer &getTargetStreamer();
|
||||
MipsTargetStreamer &getTargetStreamer() const;
|
||||
|
||||
void EmitInstrWithMacroNoAT(const MachineInstr *MI);
|
||||
|
||||
@@ -60,6 +60,11 @@ private:
|
||||
std::map<const char *, const llvm::Mips16HardFloatInfo::FuncSignature *>
|
||||
StubsNeeded;
|
||||
|
||||
void emitInlineAsmStart(const MCSubtargetInfo &StartInfo) const override;
|
||||
|
||||
void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
|
||||
const MCSubtargetInfo *EndInfo) const override;
|
||||
|
||||
void EmitJal(MCSymbol *Symbol);
|
||||
|
||||
void EmitInstrReg(unsigned Opcode, unsigned Reg);
|
||||
|
||||
Reference in new issue
Block a user