0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 //===-- MipsAsmPrinter.h - Mips LLVM Assembly Printer ----------*- C++ -*--===//
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 //
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
3 // The LLVM Compiler Infrastructure
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
4 //
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 // This file is distributed under the University of Illinois Open Source
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 // License. See LICENSE.TXT for details.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 //
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 //===----------------------------------------------------------------------===//
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9 //
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 // Mips Assembly printer class.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11 //
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12 //===----------------------------------------------------------------------===//
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13
|
77
|
14 #ifndef LLVM_LIB_TARGET_MIPS_MIPSASMPRINTER_H
|
|
15 #define LLVM_LIB_TARGET_MIPS_MIPSASMPRINTER_H
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16
|
77
|
17 #include "Mips16HardFloatInfo.h"
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
18 #include "MipsMCInstLower.h"
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
19 #include "MipsMachineFunction.h"
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
20 #include "MipsSubtarget.h"
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
21 #include "llvm/CodeGen/AsmPrinter.h"
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
22 #include "llvm/Support/Compiler.h"
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 #include "llvm/Target/TargetMachine.h"
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
24
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
25 namespace llvm {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
26 class MCStreamer;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
27 class MachineInstr;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
28 class MachineBasicBlock;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
29 class MipsTargetStreamer;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
30 class Module;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
31 class raw_ostream;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
32
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
33 class LLVM_LIBRARY_VISIBILITY MipsAsmPrinter : public AsmPrinter {
|
83
|
34 MipsTargetStreamer &getTargetStreamer() const;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
35
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
36 void EmitInstrWithMacroNoAT(const MachineInstr *MI);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
37
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
38 private:
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
39 // tblgen'erated function.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
40 bool emitPseudoExpansionLowering(MCStreamer &OutStreamer,
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
41 const MachineInstr *MI);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
42
|
77
|
43 // Emit PseudoReturn, PseudoReturn64, PseudoIndirectBranch,
|
|
44 // and PseudoIndirectBranch64 as a JR, JR_MM, JALR, or JALR64 as appropriate
|
|
45 // for the target.
|
|
46 void emitPseudoIndirectBranch(MCStreamer &OutStreamer,
|
|
47 const MachineInstr *MI);
|
|
48
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
49 // lowerOperand - Convert a MachineOperand into the equivalent MCOperand.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
50 bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
51
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
52 /// MCP - Keep a pointer to constantpool entries of the current
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
53 /// MachineFunction.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
54 const MachineConstantPool *MCP;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
55
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
56 /// InConstantPool - Maintain state when emitting a sequence of constant
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
57 /// pool entries so we can properly mark them as data regions.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
58 bool InConstantPool;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
59
|
77
|
60 std::map<const char *, const llvm::Mips16HardFloatInfo::FuncSignature *>
|
|
61 StubsNeeded;
|
|
62
|
95
|
63 void emitInlineAsmStart() const override;
|
83
|
64
|
|
65 void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
|
|
66 const MCSubtargetInfo *EndInfo) const override;
|
|
67
|
95
|
68 void EmitJal(const MCSubtargetInfo &STI, MCSymbol *Symbol);
|
77
|
69
|
95
|
70 void EmitInstrReg(const MCSubtargetInfo &STI, unsigned Opcode, unsigned Reg);
|
77
|
71
|
95
|
72 void EmitInstrRegReg(const MCSubtargetInfo &STI, unsigned Opcode,
|
|
73 unsigned Reg1, unsigned Reg2);
|
77
|
74
|
95
|
75 void EmitInstrRegRegReg(const MCSubtargetInfo &STI, unsigned Opcode,
|
|
76 unsigned Reg1, unsigned Reg2, unsigned Reg3);
|
77
|
77
|
95
|
78 void EmitMovFPIntPair(const MCSubtargetInfo &STI, unsigned MovOpc,
|
|
79 unsigned Reg1, unsigned Reg2, unsigned FPReg1,
|
|
80 unsigned FPReg2, bool LE);
|
77
|
81
|
95
|
82 void EmitSwapFPIntParams(const MCSubtargetInfo &STI,
|
|
83 Mips16HardFloatInfo::FPParamVariant, bool LE,
|
77
|
84 bool ToFP);
|
|
85
|
95
|
86 void EmitSwapFPIntRetval(const MCSubtargetInfo &STI,
|
|
87 Mips16HardFloatInfo::FPReturnVariant, bool LE);
|
77
|
88
|
|
89 void EmitFPCallStub(const char *, const Mips16HardFloatInfo::FuncSignature *);
|
|
90
|
|
91 void NaClAlignIndirectJumpTargets(MachineFunction &MF);
|
|
92
|
|
93 bool isLongBranchPseudo(int Opcode) const;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
94
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
95 public:
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
96
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
97 const MipsSubtarget *Subtarget;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
98 const MipsFunctionInfo *MipsFI;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
99 MipsMCInstLower MCInstLowering;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
100
|
83
|
101 explicit MipsAsmPrinter(TargetMachine &TM,
|
|
102 std::unique_ptr<MCStreamer> Streamer)
|
|
103 : AsmPrinter(TM, std::move(Streamer)), MCP(nullptr),
|
|
104 InConstantPool(false), MCInstLowering(*this) {}
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
105
|
77
|
106 const char *getPassName() const override {
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
107 return "Mips Assembly Printer";
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
108 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
109
|
77
|
110 bool runOnMachineFunction(MachineFunction &MF) override;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
111
|
77
|
112 void EmitConstantPool() override {
|
33
|
113 bool UsingConstantPools =
|
|
114 (Subtarget->inMips16Mode() && Subtarget->useConstantIslands());
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
115 if (!UsingConstantPools)
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
116 AsmPrinter::EmitConstantPool();
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
117 // we emit constant pools customly!
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
118 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
119
|
77
|
120 void EmitInstruction(const MachineInstr *MI) override;
|
|
121 void printSavedRegsBitmask();
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
122 void emitFrameDirective();
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
123 const char *getCurrentABIString() const;
|
77
|
124 void EmitFunctionEntryLabel() override;
|
|
125 void EmitFunctionBodyStart() override;
|
|
126 void EmitFunctionBodyEnd() override;
|
95
|
127 void EmitBasicBlockEnd(const MachineBasicBlock &MBB) override;
|
77
|
128 bool isBlockOnlyReachableByFallthrough(
|
|
129 const MachineBasicBlock* MBB) const override;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
130 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
131 unsigned AsmVariant, const char *ExtraCode,
|
77
|
132 raw_ostream &O) override;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
133 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
134 unsigned AsmVariant, const char *ExtraCode,
|
77
|
135 raw_ostream &O) override;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
136 void printOperand(const MachineInstr *MI, int opNum, raw_ostream &O);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
137 void printUnsignedImm(const MachineInstr *MI, int opNum, raw_ostream &O);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
138 void printUnsignedImm8(const MachineInstr *MI, int opNum, raw_ostream &O);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
139 void printMemOperand(const MachineInstr *MI, int opNum, raw_ostream &O);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
140 void printMemOperandEA(const MachineInstr *MI, int opNum, raw_ostream &O);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
141 void printFCCOperand(const MachineInstr *MI, int opNum, raw_ostream &O,
|
77
|
142 const char *Modifier = nullptr);
|
83
|
143 void printRegisterList(const MachineInstr *MI, int opNum, raw_ostream &O);
|
77
|
144 void EmitStartOfAsmFile(Module &M) override;
|
|
145 void EmitEndOfAsmFile(Module &M) override;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
146 void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
147 };
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
148 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
149
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
150 #endif
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
151
|