FastISel.h revision f81eca0ab908fdcf98ae0efaa75acccc8ba40dc2
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/ADT/DenseMap.h" 1811609451a5e9921d02dea5f1b6c6cd362a3cd676Dan Gohman#ifndef NDEBUG 19dd5b58ad7be78be90390074f0df138778af5c895Dan Gohman#include "llvm/ADT/SmallSet.h" 2011609451a5e9921d02dea5f1b6c6cd362a3cd676Dan Gohman#endif 21833ec1deed4568410e4fdfa0de9021d32c1479ffDan Gohman#include "llvm/CodeGen/ValueTypes.h" 22b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman 23b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmannamespace llvm { 24b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman 250586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohmanclass AllocaInst; 2610df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohmanclass ConstantFP; 27dd5b58ad7be78be90390074f0df138778af5c895Dan Gohmanclass Instruction; 28b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmanclass MachineBasicBlock; 2995267a1e671efc3c14e916b6978bbb15973b4cdcOwen Andersonclass MachineConstantPool; 30b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmanclass MachineFunction; 31f81eca0ab908fdcf98ae0efaa75acccc8ba40dc2Dan Gohmanclass MachineInstr; 320586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohmanclass MachineFrameInfo; 33bb466331e7e50d03497ce40ee344870236fd9c32Dan Gohmanclass MachineRegisterInfo; 3483785c80968165b30fcdd111ceb2c28d38bcff86Evan Chengclass TargetData; 35b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmanclass TargetInstrInfo; 3683785c80968165b30fcdd111ceb2c28d38bcff86Evan Chengclass TargetLowering; 3722bb31103de3337f0bb74c7bee16d1817d4dca14Dan Gohmanclass TargetMachine; 38b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmanclass TargetRegisterClass; 39b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman 4040610241d00e219341ff4b7106c5baff08ad407bDan Gohman/// FastISel - This is a fast-path instruction selection class that 4140610241d00e219341ff4b7106c5baff08ad407bDan Gohman/// generates poor code and doesn't support illegal types or non-trivial 4240610241d00e219341ff4b7106c5baff08ad407bDan Gohman/// lowering, but runs quickly. 43b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmanclass FastISel { 4422bb31103de3337f0bb74c7bee16d1817d4dca14Dan Gohmanprotected: 45b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman MachineBasicBlock *MBB; 46104e4ce1629ea84736691bd1ee7867bdf90e8a2eDan Gohman DenseMap<const Value *, unsigned> LocalValueMap; 473df24e667f04a7003342b534310919abc9c87418Dan Gohman DenseMap<const Value *, unsigned> &ValueMap; 483df24e667f04a7003342b534310919abc9c87418Dan Gohman DenseMap<const BasicBlock *, MachineBasicBlock *> &MBBMap; 490586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman DenseMap<const AllocaInst *, int> &StaticAllocaMap; 50f81eca0ab908fdcf98ae0efaa75acccc8ba40dc2Dan Gohman std::vector<std::pair<MachineInstr*, unsigned> > &PHINodesToUpdate; 51dd5b58ad7be78be90390074f0df138778af5c895Dan Gohman#ifndef NDEBUG 522520864773dcb73d76d297605f4bc41c0cf3fa39Dan Gohman SmallSet<const Instruction *, 8> &CatchInfoLost; 53dd5b58ad7be78be90390074f0df138778af5c895Dan Gohman#endif 54bb466331e7e50d03497ce40ee344870236fd9c32Dan Gohman MachineFunction &MF; 55bb466331e7e50d03497ce40ee344870236fd9c32Dan Gohman MachineRegisterInfo &MRI; 560586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman MachineFrameInfo &MFI; 570586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman MachineConstantPool &MCP; 589bc96a57206cbebaa9b0ba9979f949eb10c1592cBill Wendling DebugLoc DL; 5922bb31103de3337f0bb74c7bee16d1817d4dca14Dan Gohman const TargetMachine &TM; 6083785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng const TargetData &TD; 61bb466331e7e50d03497ce40ee344870236fd9c32Dan Gohman const TargetInstrInfo &TII; 6222bb31103de3337f0bb74c7bee16d1817d4dca14Dan Gohman const TargetLowering &TLI; 63b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman 64b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmanpublic: 659bc96a57206cbebaa9b0ba9979f949eb10c1592cBill Wendling /// startNewBlock - Set the current block to which generated machine 669bc96a57206cbebaa9b0ba9979f949eb10c1592cBill Wendling /// instructions will be appended, and clear the local CSE map. 67241f464d24a6c22721607841069bbeb17b3f71e6Dan Gohman /// 68241f464d24a6c22721607841069bbeb17b3f71e6Dan Gohman void startNewBlock(MachineBasicBlock *mbb) { 69241f464d24a6c22721607841069bbeb17b3f71e6Dan Gohman setCurrentBlock(mbb); 70241f464d24a6c22721607841069bbeb17b3f71e6Dan Gohman LocalValueMap.clear(); 71241f464d24a6c22721607841069bbeb17b3f71e6Dan Gohman } 72241f464d24a6c22721607841069bbeb17b3f71e6Dan Gohman 739bc96a57206cbebaa9b0ba9979f949eb10c1592cBill Wendling /// setCurrentBlock - Set the current block to which generated machine 749bc96a57206cbebaa9b0ba9979f949eb10c1592cBill Wendling /// instructions will be appended. 753df24e667f04a7003342b534310919abc9c87418Dan Gohman /// 763df24e667f04a7003342b534310919abc9c87418Dan Gohman void setCurrentBlock(MachineBasicBlock *mbb) { 773df24e667f04a7003342b534310919abc9c87418Dan Gohman MBB = mbb; 783df24e667f04a7003342b534310919abc9c87418Dan Gohman } 793df24e667f04a7003342b534310919abc9c87418Dan Gohman 80390f3ace34855a3d4c9e0adf468976375f8c6dc1Devang Patel /// getCurDebugLoc() - Return current debug location information. 81390f3ace34855a3d4c9e0adf468976375f8c6dc1Devang Patel DebugLoc getCurDebugLoc() const { return DL; } 82390f3ace34855a3d4c9e0adf468976375f8c6dc1Devang Patel 833df24e667f04a7003342b534310919abc9c87418Dan Gohman /// SelectInstruction - Do "fast" instruction selection for the given 843df24e667f04a7003342b534310919abc9c87418Dan Gohman /// LLVM IR instruction, and append generated machine instructions to 853df24e667f04a7003342b534310919abc9c87418Dan Gohman /// the current block. Return true if selection was successful. 863df24e667f04a7003342b534310919abc9c87418Dan Gohman /// 8746510a73e977273ec67747eb34cbdb43f815e451Dan Gohman bool SelectInstruction(const Instruction *I); 88b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman 89e2d0af4d7802a36e183897cc061747ba88819226Dan Gohman /// SelectOperator - Do "fast" instruction selection for the given 9040b189e4e257924d90aaf63bf2e12bc7bbca961aDan Gohman /// LLVM IR operator (Instruction or ConstantExpr), and append 9140b189e4e257924d90aaf63bf2e12bc7bbca961aDan Gohman /// generated machine instructions to the current block. Return true 9240b189e4e257924d90aaf63bf2e12bc7bbca961aDan Gohman /// if selection was successful. 9340b189e4e257924d90aaf63bf2e12bc7bbca961aDan Gohman /// 9446510a73e977273ec67747eb34cbdb43f815e451Dan Gohman bool SelectOperator(const User *I, unsigned Opcode); 9540b189e4e257924d90aaf63bf2e12bc7bbca961aDan Gohman 963df24e667f04a7003342b534310919abc9c87418Dan Gohman /// getRegForValue - Create a virtual register and arrange for it to 973df24e667f04a7003342b534310919abc9c87418Dan Gohman /// be assigned the value for the given LLVM value. 9846510a73e977273ec67747eb34cbdb43f815e451Dan Gohman unsigned getRegForValue(const Value *V); 9999b218218c0ca3ebfdd568ddfeafa07842e9d69dDan Gohman 10059fbc80f6b3b5c71dfb84149f589625f7ed510e3Evan Cheng /// lookUpRegForValue - Look up the value to see if its value is already 10159fbc80f6b3b5c71dfb84149f589625f7ed510e3Evan Cheng /// cached in a register. It may be defined by instructions across blocks or 10259fbc80f6b3b5c71dfb84149f589625f7ed510e3Evan Cheng /// defined locally. 10346510a73e977273ec67747eb34cbdb43f815e451Dan Gohman unsigned lookUpRegForValue(const Value *V); 10459fbc80f6b3b5c71dfb84149f589625f7ed510e3Evan Cheng 105c8a1a3c426209e9c7b35e279e1578a89edc40af6Dan Gohman /// getRegForGEPIndex - This is a wrapper around getRegForValue that also 106c8a1a3c426209e9c7b35e279e1578a89edc40af6Dan Gohman /// takes care of truncating or sign-extending the given getelementptr 107c8a1a3c426209e9c7b35e279e1578a89edc40af6Dan Gohman /// index value. 10846510a73e977273ec67747eb34cbdb43f815e451Dan Gohman unsigned getRegForGEPIndex(const Value *V); 109c8a1a3c426209e9c7b35e279e1578a89edc40af6Dan Gohman 110f81eca0ab908fdcf98ae0efaa75acccc8ba40dc2Dan Gohman /// HandlePHINodesInSuccessorBlocks - Handle PHI nodes in successor blocks. 111f81eca0ab908fdcf98ae0efaa75acccc8ba40dc2Dan Gohman /// Emit code to ensure constants are copied into registers when needed. 112f81eca0ab908fdcf98ae0efaa75acccc8ba40dc2Dan Gohman /// Remember the virtual registers that need to be added to the Machine PHI 113f81eca0ab908fdcf98ae0efaa75acccc8ba40dc2Dan Gohman /// nodes as input. We cannot just directly add them, because expansion 114f81eca0ab908fdcf98ae0efaa75acccc8ba40dc2Dan Gohman /// might result in multiple MBB's for one BB. As such, the start of the 115f81eca0ab908fdcf98ae0efaa75acccc8ba40dc2Dan Gohman /// BB might correspond to a different MBB than the end. 116f81eca0ab908fdcf98ae0efaa75acccc8ba40dc2Dan Gohman bool HandlePHINodesInSuccessorBlocks(const BasicBlock *LLVMBB); 117f81eca0ab908fdcf98ae0efaa75acccc8ba40dc2Dan Gohman 118cc8430f742b0f1e567292c8a776e94fc1c930b2aDan Gohman virtual ~FastISel(); 119cc8430f742b0f1e567292c8a776e94fc1c930b2aDan Gohman 120b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmanprotected: 1213df24e667f04a7003342b534310919abc9c87418Dan Gohman FastISel(MachineFunction &mf, 1223df24e667f04a7003342b534310919abc9c87418Dan Gohman DenseMap<const Value *, unsigned> &vm, 1230586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman DenseMap<const BasicBlock *, MachineBasicBlock *> &bm, 124f81eca0ab908fdcf98ae0efaa75acccc8ba40dc2Dan Gohman DenseMap<const AllocaInst *, int> &am, 125f81eca0ab908fdcf98ae0efaa75acccc8ba40dc2Dan Gohman std::vector<std::pair<MachineInstr*, unsigned> > &PHINodesToUpdate 126dd5b58ad7be78be90390074f0df138778af5c895Dan Gohman#ifndef NDEBUG 1272520864773dcb73d76d297605f4bc41c0cf3fa39Dan Gohman , SmallSet<const Instruction *, 8> &cil 128dd5b58ad7be78be90390074f0df138778af5c895Dan Gohman#endif 129dd5b58ad7be78be90390074f0df138778af5c895Dan Gohman ); 130e285a74f7cf9dd3ccf4fe758576cf83301f8a43eDan Gohman 1316e3ff375474c4fd78feb0b8463eb273a23cb4404Dan Gohman /// TargetSelectInstruction - This method is called by target-independent 1326e3ff375474c4fd78feb0b8463eb273a23cb4404Dan Gohman /// code when the normal FastISel process fails to select an instruction. 1336e3ff375474c4fd78feb0b8463eb273a23cb4404Dan Gohman /// This gives targets a chance to emit code for anything that doesn't 1346e3ff375474c4fd78feb0b8463eb273a23cb4404Dan Gohman /// fit into FastISel's framework. It returns true if it was successful. 1356e3ff375474c4fd78feb0b8463eb273a23cb4404Dan Gohman /// 1366e3ff375474c4fd78feb0b8463eb273a23cb4404Dan Gohman virtual bool 13746510a73e977273ec67747eb34cbdb43f815e451Dan Gohman TargetSelectInstruction(const Instruction *I) = 0; 1386e3ff375474c4fd78feb0b8463eb273a23cb4404Dan Gohman 139bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// FastEmit_r - This method is called by target-independent code 140bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// to request that an instruction with the given type and opcode 141bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// be emitted. 142825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson virtual unsigned FastEmit_(MVT VT, 143825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson MVT RetVT, 1447c3ecb6838ef7a2ca306c0f3cd68022f0855ae71Dan Gohman unsigned Opcode); 145bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman 146bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// FastEmit_r - This method is called by target-independent code 147bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// to request that an instruction with the given type, opcode, and 148bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// register operand be emitted. 149bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// 150825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson virtual unsigned FastEmit_r(MVT VT, 151825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson MVT RetVT, 1527c3ecb6838ef7a2ca306c0f3cd68022f0855ae71Dan Gohman unsigned Opcode, unsigned Op0); 153bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman 154bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// FastEmit_rr - This method is called by target-independent code 155bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// to request that an instruction with the given type, opcode, and 156bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// register operands be emitted. 157bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// 158825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson virtual unsigned FastEmit_rr(MVT VT, 159825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson MVT RetVT, 1607c3ecb6838ef7a2ca306c0f3cd68022f0855ae71Dan Gohman unsigned Opcode, 161b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman unsigned Op0, unsigned Op1); 162b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman 16383785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng /// FastEmit_ri - This method is called by target-independent code 16483785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng /// to request that an instruction with the given type, opcode, and 16583785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng /// register and immediate operands be emitted. 16683785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng /// 167825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson virtual unsigned FastEmit_ri(MVT VT, 168825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson MVT RetVT, 1697c3ecb6838ef7a2ca306c0f3cd68022f0855ae71Dan Gohman unsigned Opcode, 170d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman unsigned Op0, uint64_t Imm); 171d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman 17210df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// FastEmit_rf - This method is called by target-independent code 17310df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// to request that an instruction with the given type, opcode, and 17410df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// register and floating-point immediate operands be emitted. 17510df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// 176825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson virtual unsigned FastEmit_rf(MVT VT, 177825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson MVT RetVT, 1787c3ecb6838ef7a2ca306c0f3cd68022f0855ae71Dan Gohman unsigned Opcode, 17946510a73e977273ec67747eb34cbdb43f815e451Dan Gohman unsigned Op0, const ConstantFP *FPImm); 18010df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman 181d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// FastEmit_rri - This method is called by target-independent code 182d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// to request that an instruction with the given type, opcode, and 183d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// register and immediate operands be emitted. 184d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// 185825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson virtual unsigned FastEmit_rri(MVT VT, 186825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson MVT RetVT, 1877c3ecb6838ef7a2ca306c0f3cd68022f0855ae71Dan Gohman unsigned Opcode, 188d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman unsigned Op0, unsigned Op1, uint64_t Imm); 18983785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng 19083785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng /// FastEmit_ri_ - This method is a wrapper of FastEmit_ri. It first tries 19183785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng /// to emit an instruction with an immediate operand using FastEmit_ri. 19283785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng /// If that fails, it materializes the immediate into a register and try 19383785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng /// FastEmit_rr instead. 194825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson unsigned FastEmit_ri_(MVT VT, 1957c3ecb6838ef7a2ca306c0f3cd68022f0855ae71Dan Gohman unsigned Opcode, 19683785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng unsigned Op0, uint64_t Imm, 197825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson MVT ImmType); 1986d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson 19910df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// FastEmit_rf_ - This method is a wrapper of FastEmit_rf. It first tries 20010df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// to emit an instruction with an immediate operand using FastEmit_rf. 20110df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// If that fails, it materializes the immediate into a register and try 20210df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// FastEmit_rr instead. 203825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson unsigned FastEmit_rf_(MVT VT, 2047c3ecb6838ef7a2ca306c0f3cd68022f0855ae71Dan Gohman unsigned Opcode, 20546510a73e977273ec67747eb34cbdb43f815e451Dan Gohman unsigned Op0, const ConstantFP *FPImm, 206825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson MVT ImmType); 20710df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman 2086d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson /// FastEmit_i - This method is called by target-independent code 2096d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson /// to request that an instruction with the given type, opcode, and 2106d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson /// immediate operand be emitted. 211825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson virtual unsigned FastEmit_i(MVT VT, 212825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson MVT RetVT, 2137c3ecb6838ef7a2ca306c0f3cd68022f0855ae71Dan Gohman unsigned Opcode, 2146d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson uint64_t Imm); 21583785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng 21610df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// FastEmit_f - This method is called by target-independent code 21710df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// to request that an instruction with the given type, opcode, and 21810df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// floating-point immediate operand be emitted. 219825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson virtual unsigned FastEmit_f(MVT VT, 220825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson MVT RetVT, 2217c3ecb6838ef7a2ca306c0f3cd68022f0855ae71Dan Gohman unsigned Opcode, 22246510a73e977273ec67747eb34cbdb43f815e451Dan Gohman const ConstantFP *FPImm); 22310df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman 224bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// FastEmitInst_ - Emit a MachineInstr with no operands and a 225bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// result register in the given register class. 226bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// 227b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman unsigned FastEmitInst_(unsigned MachineInstOpcode, 228b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman const TargetRegisterClass *RC); 229bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman 230d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// FastEmitInst_r - Emit a MachineInstr with one register operand 231bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// and a result register in the given register class. 232bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// 233b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman unsigned FastEmitInst_r(unsigned MachineInstOpcode, 234b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman const TargetRegisterClass *RC, 235b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman unsigned Op0); 236bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman 237d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// FastEmitInst_rr - Emit a MachineInstr with two register operands 238bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// and a result register in the given register class. 239bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// 240b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman unsigned FastEmitInst_rr(unsigned MachineInstOpcode, 241b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman const TargetRegisterClass *RC, 242b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman unsigned Op0, unsigned Op1); 243bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman 244d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// FastEmitInst_ri - Emit a MachineInstr with two register operands 245d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// and a result register in the given register class. 246d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// 247d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman unsigned FastEmitInst_ri(unsigned MachineInstOpcode, 248d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman const TargetRegisterClass *RC, 249d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman unsigned Op0, uint64_t Imm); 250d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman 25110df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// FastEmitInst_rf - Emit a MachineInstr with two register operands 25210df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// and a result register in the given register class. 25310df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// 25410df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman unsigned FastEmitInst_rf(unsigned MachineInstOpcode, 25510df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman const TargetRegisterClass *RC, 25646510a73e977273ec67747eb34cbdb43f815e451Dan Gohman unsigned Op0, const ConstantFP *FPImm); 25710df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman 258d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// FastEmitInst_rri - Emit a MachineInstr with two register operands, 259d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// an immediate, and a result register in the given register class. 260d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// 261d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman unsigned FastEmitInst_rri(unsigned MachineInstOpcode, 262d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman const TargetRegisterClass *RC, 263d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman unsigned Op0, unsigned Op1, uint64_t Imm); 2646d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson 2656d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson /// FastEmitInst_i - Emit a MachineInstr with a single immediate 2666d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson /// operand, and a result register in the given register class. 2676d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson unsigned FastEmitInst_i(unsigned MachineInstrOpcode, 2686d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson const TargetRegisterClass *RC, 2696d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson uint64_t Imm); 270d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman 2718970f00deff00ffce1f35cf00883357e1582daa1Owen Anderson /// FastEmitInst_extractsubreg - Emit a MachineInstr for an extract_subreg 272536ab130ec95cbb7bf30530251dafa7dfecc8471Evan Cheng /// from a specified index of a superregister to a specified type. 273825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson unsigned FastEmitInst_extractsubreg(MVT RetVT, 274536ab130ec95cbb7bf30530251dafa7dfecc8471Evan Cheng unsigned Op0, uint32_t Idx); 2758970f00deff00ffce1f35cf00883357e1582daa1Owen Anderson 27614ea1ec2324cb595f2e035bbf54ddcd483f17c11Dan Gohman /// FastEmitZExtFromI1 - Emit MachineInstrs to compute the value of Op 27714ea1ec2324cb595f2e035bbf54ddcd483f17c11Dan Gohman /// with all but the least significant bit set to zero. 278825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson unsigned FastEmitZExtFromI1(MVT VT, 27914ea1ec2324cb595f2e035bbf54ddcd483f17c11Dan Gohman unsigned Op); 28014ea1ec2324cb595f2e035bbf54ddcd483f17c11Dan Gohman 281d98d6203e429b2d7208b6687931e9079e85e95ecDan Gohman /// FastEmitBranch - Emit an unconditional branch to the given block, 282d98d6203e429b2d7208b6687931e9079e85e95ecDan Gohman /// unless it is the immediate (fall-through) successor, and update 283d98d6203e429b2d7208b6687931e9079e85e95ecDan Gohman /// the CFG. 284d98d6203e429b2d7208b6687931e9079e85e95ecDan Gohman void FastEmitBranch(MachineBasicBlock *MBB); 285d98d6203e429b2d7208b6687931e9079e85e95ecDan Gohman 28646510a73e977273ec67747eb34cbdb43f815e451Dan Gohman unsigned UpdateValueMap(const Value* I, unsigned Reg); 287ea09f4f4691a0db65772b54fe8163a48c9dce01dEvan Cheng 288c7f72de3b4ef21828ea4780f0693bf0acd04e1c5Dan Gohman unsigned createResultReg(const TargetRegisterClass *RC); 28995267a1e671efc3c14e916b6978bbb15973b4cdcOwen Anderson 2909c7216f984111eb8f1716741bc9039ed86ec4a9bOwen Anderson /// TargetMaterializeConstant - Emit a constant in a register using 2919c7216f984111eb8f1716741bc9039ed86ec4a9bOwen Anderson /// target-specific logic, such as constant pool loads. 29246510a73e977273ec67747eb34cbdb43f815e451Dan Gohman virtual unsigned TargetMaterializeConstant(const Constant* C) { 2930586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman return 0; 2940586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman } 2950586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman 2960586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman /// TargetMaterializeAlloca - Emit an alloca address in a register using 2970586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman /// target-specific logic. 29846510a73e977273ec67747eb34cbdb43f815e451Dan Gohman virtual unsigned TargetMaterializeAlloca(const AllocaInst* C) { 29995267a1e671efc3c14e916b6978bbb15973b4cdcOwen Anderson return 0; 30095267a1e671efc3c14e916b6978bbb15973b4cdcOwen Anderson } 301c7f72de3b4ef21828ea4780f0693bf0acd04e1c5Dan Gohman 302ea09f4f4691a0db65772b54fe8163a48c9dce01dEvan Chengprivate: 30346510a73e977273ec67747eb34cbdb43f815e451Dan Gohman bool SelectBinaryOp(const User *I, unsigned ISDOpcode); 304bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman 30546510a73e977273ec67747eb34cbdb43f815e451Dan Gohman bool SelectFNeg(const User *I); 3063d45a853db014fdddcdb79424e663dfed5eccbc7Dan Gohman 30746510a73e977273ec67747eb34cbdb43f815e451Dan Gohman bool SelectGetElementPtr(const User *I); 308763d89343be210eb62a13318ca0cc9321ce46bfbDan Gohman 30946510a73e977273ec67747eb34cbdb43f815e451Dan Gohman bool SelectCall(const User *I); 31033134c4a75558288d663267c8991f6bd37a530afDan Gohman 31146510a73e977273ec67747eb34cbdb43f815e451Dan Gohman bool SelectBitCast(const User *I); 312d0533c9998d3baf41848ba559a9b2f2c65296d14Owen Anderson 31346510a73e977273ec67747eb34cbdb43f815e451Dan Gohman bool SelectCast(const User *I, unsigned Opcode); 314b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman}; 315b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman 316b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman} 317b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman 318b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman#endif 319