FastISel.h revision 0586d91bb3e516d5826826522d9a90ed6ef74d86
1b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman//===-- FastISel.h - Definition of the FastISel class ---------------------===// 2b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman// 3b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman// The LLVM Compiler Infrastructure 4b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman// 5b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman// This file is distributed under the University of Illinois Open Source 6b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman// License. See LICENSE.TXT for details. 7b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman// 8b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman//===----------------------------------------------------------------------===// 9b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman// 10b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman// This file defines the FastISel class. 11b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman// 12b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman//===----------------------------------------------------------------------===// 13b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman 14b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman#ifndef LLVM_CODEGEN_FASTISEL_H 15b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman#define LLVM_CODEGEN_FASTISEL_H 16b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman 17b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman#include "llvm/BasicBlock.h" 18b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman#include "llvm/ADT/DenseMap.h" 19b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman#include "llvm/CodeGen/SelectionDAGNodes.h" 20b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman 21b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmannamespace llvm { 22b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman 230586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohmanclass AllocaInst; 2410df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohmanclass ConstantFP; 25b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmanclass MachineBasicBlock; 2695267a1e671efc3c14e916b6978bbb15973b4cdcOwen Andersonclass MachineConstantPool; 27b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmanclass MachineFunction; 280586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohmanclass MachineFrameInfo; 29bb466331e7e50d03497ce40ee344870236fd9c32Dan Gohmanclass MachineRegisterInfo; 3083785c80968165b30fcdd111ceb2c28d38bcff86Evan Chengclass TargetData; 31b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmanclass TargetInstrInfo; 3283785c80968165b30fcdd111ceb2c28d38bcff86Evan Chengclass TargetLowering; 3322bb31103de3337f0bb74c7bee16d1817d4dca14Dan Gohmanclass TargetMachine; 34b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmanclass TargetRegisterClass; 35b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman 3640610241d00e219341ff4b7106c5baff08ad407bDan Gohman/// FastISel - This is a fast-path instruction selection class that 3740610241d00e219341ff4b7106c5baff08ad407bDan Gohman/// generates poor code and doesn't support illegal types or non-trivial 3840610241d00e219341ff4b7106c5baff08ad407bDan Gohman/// lowering, but runs quickly. 39b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmanclass FastISel { 4022bb31103de3337f0bb74c7bee16d1817d4dca14Dan Gohmanprotected: 41b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman MachineBasicBlock *MBB; 42104e4ce1629ea84736691bd1ee7867bdf90e8a2eDan Gohman DenseMap<const Value *, unsigned> LocalValueMap; 433df24e667f04a7003342b534310919abc9c87418Dan Gohman DenseMap<const Value *, unsigned> &ValueMap; 443df24e667f04a7003342b534310919abc9c87418Dan Gohman DenseMap<const BasicBlock *, MachineBasicBlock *> &MBBMap; 450586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman DenseMap<const AllocaInst *, int> &StaticAllocaMap; 46bb466331e7e50d03497ce40ee344870236fd9c32Dan Gohman MachineFunction &MF; 47bb466331e7e50d03497ce40ee344870236fd9c32Dan Gohman MachineRegisterInfo &MRI; 480586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman MachineFrameInfo &MFI; 490586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman MachineConstantPool &MCP; 5022bb31103de3337f0bb74c7bee16d1817d4dca14Dan Gohman const TargetMachine &TM; 5183785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng const TargetData &TD; 52bb466331e7e50d03497ce40ee344870236fd9c32Dan Gohman const TargetInstrInfo &TII; 5322bb31103de3337f0bb74c7bee16d1817d4dca14Dan Gohman const TargetLowering &TLI; 54b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman 55b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmanpublic: 563df24e667f04a7003342b534310919abc9c87418Dan Gohman /// setCurrentBlock - Set the current block, to which generated 573df24e667f04a7003342b534310919abc9c87418Dan Gohman /// machine instructions will be appended. 583df24e667f04a7003342b534310919abc9c87418Dan Gohman /// 593df24e667f04a7003342b534310919abc9c87418Dan Gohman void setCurrentBlock(MachineBasicBlock *mbb) { 603df24e667f04a7003342b534310919abc9c87418Dan Gohman MBB = mbb; 613df24e667f04a7003342b534310919abc9c87418Dan Gohman } 623df24e667f04a7003342b534310919abc9c87418Dan Gohman 633df24e667f04a7003342b534310919abc9c87418Dan Gohman /// SelectInstruction - Do "fast" instruction selection for the given 643df24e667f04a7003342b534310919abc9c87418Dan Gohman /// LLVM IR instruction, and append generated machine instructions to 653df24e667f04a7003342b534310919abc9c87418Dan Gohman /// the current block. Return true if selection was successful. 663df24e667f04a7003342b534310919abc9c87418Dan Gohman /// 673df24e667f04a7003342b534310919abc9c87418Dan Gohman bool SelectInstruction(Instruction *I); 68b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman 6940b189e4e257924d90aaf63bf2e12bc7bbca961aDan Gohman /// SelectInstruction - Do "fast" instruction selection for the given 7040b189e4e257924d90aaf63bf2e12bc7bbca961aDan Gohman /// LLVM IR operator (Instruction or ConstantExpr), and append 7140b189e4e257924d90aaf63bf2e12bc7bbca961aDan Gohman /// generated machine instructions to the current block. Return true 7240b189e4e257924d90aaf63bf2e12bc7bbca961aDan Gohman /// if selection was successful. 7340b189e4e257924d90aaf63bf2e12bc7bbca961aDan Gohman /// 7440b189e4e257924d90aaf63bf2e12bc7bbca961aDan Gohman bool SelectOperator(User *I, unsigned Opcode); 7540b189e4e257924d90aaf63bf2e12bc7bbca961aDan Gohman 7699b218218c0ca3ebfdd568ddfeafa07842e9d69dDan Gohman /// TargetSelectInstruction - This method is called by target-independent 7799b218218c0ca3ebfdd568ddfeafa07842e9d69dDan Gohman /// code when the normal FastISel process fails to select an instruction. 7899b218218c0ca3ebfdd568ddfeafa07842e9d69dDan Gohman /// This gives targets a chance to emit code for anything that doesn't 7999b218218c0ca3ebfdd568ddfeafa07842e9d69dDan Gohman /// fit into FastISel's framework. It returns true if it was successful. 8099b218218c0ca3ebfdd568ddfeafa07842e9d69dDan Gohman /// 8199b218218c0ca3ebfdd568ddfeafa07842e9d69dDan Gohman virtual bool 823df24e667f04a7003342b534310919abc9c87418Dan Gohman TargetSelectInstruction(Instruction *I) = 0; 833df24e667f04a7003342b534310919abc9c87418Dan Gohman 843df24e667f04a7003342b534310919abc9c87418Dan Gohman /// getRegForValue - Create a virtual register and arrange for it to 853df24e667f04a7003342b534310919abc9c87418Dan Gohman /// be assigned the value for the given LLVM value. 863df24e667f04a7003342b534310919abc9c87418Dan Gohman unsigned getRegForValue(Value *V); 8799b218218c0ca3ebfdd568ddfeafa07842e9d69dDan Gohman 8859fbc80f6b3b5c71dfb84149f589625f7ed510e3Evan Cheng /// lookUpRegForValue - Look up the value to see if its value is already 8959fbc80f6b3b5c71dfb84149f589625f7ed510e3Evan Cheng /// cached in a register. It may be defined by instructions across blocks or 9059fbc80f6b3b5c71dfb84149f589625f7ed510e3Evan Cheng /// defined locally. 9159fbc80f6b3b5c71dfb84149f589625f7ed510e3Evan Cheng unsigned lookUpRegForValue(Value *V); 9259fbc80f6b3b5c71dfb84149f589625f7ed510e3Evan Cheng 93cc8430f742b0f1e567292c8a776e94fc1c930b2aDan Gohman virtual ~FastISel(); 94cc8430f742b0f1e567292c8a776e94fc1c930b2aDan Gohman 95b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmanprotected: 963df24e667f04a7003342b534310919abc9c87418Dan Gohman FastISel(MachineFunction &mf, 973df24e667f04a7003342b534310919abc9c87418Dan Gohman DenseMap<const Value *, unsigned> &vm, 980586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman DenseMap<const BasicBlock *, MachineBasicBlock *> &bm, 990586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman DenseMap<const AllocaInst *, int> &am); 100e285a74f7cf9dd3ccf4fe758576cf83301f8a43eDan Gohman 101bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// FastEmit_r - This method is called by target-independent code 102bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// to request that an instruction with the given type and opcode 103bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// be emitted. 104b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman virtual unsigned FastEmit_(MVT::SimpleValueType VT, 1050f84e4e31009eecf2dfcbe6113b65d0919f30254Owen Anderson MVT::SimpleValueType RetVT, 106b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman ISD::NodeType Opcode); 107bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman 108bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// FastEmit_r - This method is called by target-independent code 109bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// to request that an instruction with the given type, opcode, and 110bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// register operand be emitted. 111bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// 112b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman virtual unsigned FastEmit_r(MVT::SimpleValueType VT, 1130f84e4e31009eecf2dfcbe6113b65d0919f30254Owen Anderson MVT::SimpleValueType RetVT, 114b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman ISD::NodeType Opcode, unsigned Op0); 115bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman 116bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// FastEmit_rr - This method is called by target-independent code 117bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// to request that an instruction with the given type, opcode, and 118bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// register operands be emitted. 119bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// 120b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman virtual unsigned FastEmit_rr(MVT::SimpleValueType VT, 1210f84e4e31009eecf2dfcbe6113b65d0919f30254Owen Anderson MVT::SimpleValueType RetVT, 122b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman ISD::NodeType Opcode, 123b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman unsigned Op0, unsigned Op1); 124b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman 12583785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng /// FastEmit_ri - This method is called by target-independent code 12683785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng /// to request that an instruction with the given type, opcode, and 12783785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng /// register and immediate operands be emitted. 12883785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng /// 12983785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng virtual unsigned FastEmit_ri(MVT::SimpleValueType VT, 1300f84e4e31009eecf2dfcbe6113b65d0919f30254Owen Anderson MVT::SimpleValueType RetVT, 13183785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng ISD::NodeType Opcode, 132d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman unsigned Op0, uint64_t Imm); 133d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman 13410df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// FastEmit_rf - This method is called by target-independent code 13510df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// to request that an instruction with the given type, opcode, and 13610df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// register and floating-point immediate operands be emitted. 13710df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// 13810df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman virtual unsigned FastEmit_rf(MVT::SimpleValueType VT, 13910df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman MVT::SimpleValueType RetVT, 14010df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman ISD::NodeType Opcode, 14110df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman unsigned Op0, ConstantFP *FPImm); 14210df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman 143d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// FastEmit_rri - This method is called by target-independent code 144d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// to request that an instruction with the given type, opcode, and 145d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// register and immediate operands be emitted. 146d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// 147d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman virtual unsigned FastEmit_rri(MVT::SimpleValueType VT, 1480f84e4e31009eecf2dfcbe6113b65d0919f30254Owen Anderson MVT::SimpleValueType RetVT, 149d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman ISD::NodeType Opcode, 150d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman unsigned Op0, unsigned Op1, uint64_t Imm); 15183785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng 15283785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng /// FastEmit_ri_ - This method is a wrapper of FastEmit_ri. It first tries 15383785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng /// to emit an instruction with an immediate operand using FastEmit_ri. 15483785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng /// If that fails, it materializes the immediate into a register and try 15583785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng /// FastEmit_rr instead. 15683785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng unsigned FastEmit_ri_(MVT::SimpleValueType VT, 15783785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng ISD::NodeType Opcode, 15883785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng unsigned Op0, uint64_t Imm, 15983785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng MVT::SimpleValueType ImmType); 1606d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson 16110df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// FastEmit_rf_ - This method is a wrapper of FastEmit_rf. It first tries 16210df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// to emit an instruction with an immediate operand using FastEmit_rf. 16310df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// If that fails, it materializes the immediate into a register and try 16410df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// FastEmit_rr instead. 16510df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman unsigned FastEmit_rf_(MVT::SimpleValueType VT, 16610df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman ISD::NodeType Opcode, 16710df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman unsigned Op0, ConstantFP *FPImm, 16810df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman MVT::SimpleValueType ImmType); 16910df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman 1706d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson /// FastEmit_i - This method is called by target-independent code 1716d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson /// to request that an instruction with the given type, opcode, and 1726d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson /// immediate operand be emitted. 1736d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson virtual unsigned FastEmit_i(MVT::SimpleValueType VT, 1740f84e4e31009eecf2dfcbe6113b65d0919f30254Owen Anderson MVT::SimpleValueType RetVT, 1756d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson ISD::NodeType Opcode, 1766d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson uint64_t Imm); 17783785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng 17810df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// FastEmit_f - This method is called by target-independent code 17910df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// to request that an instruction with the given type, opcode, and 18010df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// floating-point immediate operand be emitted. 18110df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman virtual unsigned FastEmit_f(MVT::SimpleValueType VT, 18210df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman MVT::SimpleValueType RetVT, 18310df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman ISD::NodeType Opcode, 18410df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman ConstantFP *FPImm); 18510df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman 186bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// FastEmitInst_ - Emit a MachineInstr with no operands and a 187bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// result register in the given register class. 188bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// 189b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman unsigned FastEmitInst_(unsigned MachineInstOpcode, 190b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman const TargetRegisterClass *RC); 191bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman 192d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// FastEmitInst_r - Emit a MachineInstr with one register operand 193bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// and a result register in the given register class. 194bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// 195b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman unsigned FastEmitInst_r(unsigned MachineInstOpcode, 196b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman const TargetRegisterClass *RC, 197b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman unsigned Op0); 198bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman 199d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// FastEmitInst_rr - Emit a MachineInstr with two register operands 200bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// and a result register in the given register class. 201bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// 202b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman unsigned FastEmitInst_rr(unsigned MachineInstOpcode, 203b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman const TargetRegisterClass *RC, 204b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman unsigned Op0, unsigned Op1); 205bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman 206d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// FastEmitInst_ri - Emit a MachineInstr with two register operands 207d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// and a result register in the given register class. 208d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// 209d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman unsigned FastEmitInst_ri(unsigned MachineInstOpcode, 210d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman const TargetRegisterClass *RC, 211d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman unsigned Op0, uint64_t Imm); 212d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman 21310df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// FastEmitInst_rf - Emit a MachineInstr with two register operands 21410df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// and a result register in the given register class. 21510df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// 21610df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman unsigned FastEmitInst_rf(unsigned MachineInstOpcode, 21710df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman const TargetRegisterClass *RC, 21810df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman unsigned Op0, ConstantFP *FPImm); 21910df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman 220d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// FastEmitInst_rri - Emit a MachineInstr with two register operands, 221d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// an immediate, and a result register in the given register class. 222d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// 223d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman unsigned FastEmitInst_rri(unsigned MachineInstOpcode, 224d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman const TargetRegisterClass *RC, 225d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman unsigned Op0, unsigned Op1, uint64_t Imm); 2266d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson 2276d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson /// FastEmitInst_i - Emit a MachineInstr with a single immediate 2286d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson /// operand, and a result register in the given register class. 2296d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson unsigned FastEmitInst_i(unsigned MachineInstrOpcode, 2306d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson const TargetRegisterClass *RC, 2316d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson uint64_t Imm); 232d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman 2338970f00deff00ffce1f35cf00883357e1582daa1Owen Anderson /// FastEmitInst_extractsubreg - Emit a MachineInstr for an extract_subreg 2348970f00deff00ffce1f35cf00883357e1582daa1Owen Anderson /// from a specified index of a superregister. 23540a468f24909792f000e3ccc1dda7a27b9c34b69Owen Anderson unsigned FastEmitInst_extractsubreg(unsigned Op0, uint32_t Idx); 2368970f00deff00ffce1f35cf00883357e1582daa1Owen Anderson 23795267a1e671efc3c14e916b6978bbb15973b4cdcOwen Anderson void UpdateValueMap(Value* I, unsigned Reg); 238ea09f4f4691a0db65772b54fe8163a48c9dce01dEvan Cheng 239c7f72de3b4ef21828ea4780f0693bf0acd04e1c5Dan Gohman unsigned createResultReg(const TargetRegisterClass *RC); 24095267a1e671efc3c14e916b6978bbb15973b4cdcOwen Anderson 2419c7216f984111eb8f1716741bc9039ed86ec4a9bOwen Anderson /// TargetMaterializeConstant - Emit a constant in a register using 2429c7216f984111eb8f1716741bc9039ed86ec4a9bOwen Anderson /// target-specific logic, such as constant pool loads. 2430586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman virtual unsigned TargetMaterializeConstant(Constant* C) { 2440586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman return 0; 2450586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman } 2460586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman 2470586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman /// TargetMaterializeAlloca - Emit an alloca address in a register using 2480586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman /// target-specific logic. 2490586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman virtual unsigned TargetMaterializeAlloca(AllocaInst* C) { 25095267a1e671efc3c14e916b6978bbb15973b4cdcOwen Anderson return 0; 25195267a1e671efc3c14e916b6978bbb15973b4cdcOwen Anderson } 252c7f72de3b4ef21828ea4780f0693bf0acd04e1c5Dan Gohman 253ea09f4f4691a0db65772b54fe8163a48c9dce01dEvan Chengprivate: 25440b189e4e257924d90aaf63bf2e12bc7bbca961aDan Gohman bool SelectBinaryOp(User *I, ISD::NodeType ISDOpcode); 255bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman 25640b189e4e257924d90aaf63bf2e12bc7bbca961aDan Gohman bool SelectGetElementPtr(User *I); 257763d89343be210eb62a13318ca0cc9321ce46bfbDan Gohman 25840b189e4e257924d90aaf63bf2e12bc7bbca961aDan Gohman bool SelectBitCast(User *I); 259d0533c9998d3baf41848ba559a9b2f2c65296d14Owen Anderson 26040b189e4e257924d90aaf63bf2e12bc7bbca961aDan Gohman bool SelectCast(User *I, ISD::NodeType Opcode); 261b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman}; 262b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman 263b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman} 264b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman 265b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman#endif 266