FastISel.h revision 9bc96a57206cbebaa9b0ba9979f949eb10c1592c
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" 18dd5b58ad7be78be90390074f0df138778af5c895Dan Gohman#include "llvm/ADT/SmallSet.h" 199bc96a57206cbebaa9b0ba9979f949eb10c1592cBill Wendling#include "llvm/CodeGen/DebugLoc.h" 20b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman#include "llvm/CodeGen/SelectionDAGNodes.h" 21b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman 22b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmannamespace llvm { 23b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman 240586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohmanclass AllocaInst; 2510df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohmanclass ConstantFP; 26dd5b58ad7be78be90390074f0df138778af5c895Dan Gohmanclass Instruction; 27b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmanclass MachineBasicBlock; 2895267a1e671efc3c14e916b6978bbb15973b4cdcOwen Andersonclass MachineConstantPool; 29b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmanclass MachineFunction; 300586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohmanclass MachineFrameInfo; 31d57dd5f4e6740520820bc0fca42a540e31c27a73Dan Gohmanclass MachineModuleInfo; 3283489bb7700c69b7a4a8da59365c42d3f5c8129bDevang Patelclass DwarfWriter; 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; 50dd5b58ad7be78be90390074f0df138778af5c895Dan Gohman#ifndef NDEBUG 51dd5b58ad7be78be90390074f0df138778af5c895Dan Gohman SmallSet<Instruction*, 8> &CatchInfoLost; 52dd5b58ad7be78be90390074f0df138778af5c895Dan Gohman#endif 53bb466331e7e50d03497ce40ee344870236fd9c32Dan Gohman MachineFunction &MF; 54d57dd5f4e6740520820bc0fca42a540e31c27a73Dan Gohman MachineModuleInfo *MMI; 5583489bb7700c69b7a4a8da59365c42d3f5c8129bDevang Patel DwarfWriter *DW; 56bb466331e7e50d03497ce40ee344870236fd9c32Dan Gohman MachineRegisterInfo &MRI; 570586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman MachineFrameInfo &MFI; 580586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman MachineConstantPool &MCP; 599bc96a57206cbebaa9b0ba9979f949eb10c1592cBill Wendling DebugLoc DL; 6022bb31103de3337f0bb74c7bee16d1817d4dca14Dan Gohman const TargetMachine &TM; 6183785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng const TargetData &TD; 62bb466331e7e50d03497ce40ee344870236fd9c32Dan Gohman const TargetInstrInfo &TII; 6322bb31103de3337f0bb74c7bee16d1817d4dca14Dan Gohman const TargetLowering &TLI; 64b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman 65b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmanpublic: 669bc96a57206cbebaa9b0ba9979f949eb10c1592cBill Wendling /// startNewBlock - Set the current block to which generated machine 679bc96a57206cbebaa9b0ba9979f949eb10c1592cBill Wendling /// instructions will be appended, and clear the local CSE map. 68241f464d24a6c22721607841069bbeb17b3f71e6Dan Gohman /// 69241f464d24a6c22721607841069bbeb17b3f71e6Dan Gohman void startNewBlock(MachineBasicBlock *mbb) { 70241f464d24a6c22721607841069bbeb17b3f71e6Dan Gohman setCurrentBlock(mbb); 71241f464d24a6c22721607841069bbeb17b3f71e6Dan Gohman LocalValueMap.clear(); 72241f464d24a6c22721607841069bbeb17b3f71e6Dan Gohman } 73241f464d24a6c22721607841069bbeb17b3f71e6Dan Gohman 749bc96a57206cbebaa9b0ba9979f949eb10c1592cBill Wendling /// setCurrentBlock - Set the current block to which generated machine 759bc96a57206cbebaa9b0ba9979f949eb10c1592cBill Wendling /// instructions will be appended. 763df24e667f04a7003342b534310919abc9c87418Dan Gohman /// 773df24e667f04a7003342b534310919abc9c87418Dan Gohman void setCurrentBlock(MachineBasicBlock *mbb) { 783df24e667f04a7003342b534310919abc9c87418Dan Gohman MBB = mbb; 793df24e667f04a7003342b534310919abc9c87418Dan Gohman } 803df24e667f04a7003342b534310919abc9c87418Dan Gohman 819bc96a57206cbebaa9b0ba9979f949eb10c1592cBill Wendling /// setCurDebugLoc - Set the current debug location information, which is used 829bc96a57206cbebaa9b0ba9979f949eb10c1592cBill Wendling /// when creating a machine instruction. 839bc96a57206cbebaa9b0ba9979f949eb10c1592cBill Wendling /// 849bc96a57206cbebaa9b0ba9979f949eb10c1592cBill Wendling void setCurDebugLoc(DebugLoc dl) { DL = dl; } 859bc96a57206cbebaa9b0ba9979f949eb10c1592cBill Wendling 863df24e667f04a7003342b534310919abc9c87418Dan Gohman /// SelectInstruction - Do "fast" instruction selection for the given 873df24e667f04a7003342b534310919abc9c87418Dan Gohman /// LLVM IR instruction, and append generated machine instructions to 883df24e667f04a7003342b534310919abc9c87418Dan Gohman /// the current block. Return true if selection was successful. 893df24e667f04a7003342b534310919abc9c87418Dan Gohman /// 903df24e667f04a7003342b534310919abc9c87418Dan Gohman bool SelectInstruction(Instruction *I); 91b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman 9240b189e4e257924d90aaf63bf2e12bc7bbca961aDan Gohman /// SelectInstruction - Do "fast" instruction selection for the given 9340b189e4e257924d90aaf63bf2e12bc7bbca961aDan Gohman /// LLVM IR operator (Instruction or ConstantExpr), and append 9440b189e4e257924d90aaf63bf2e12bc7bbca961aDan Gohman /// generated machine instructions to the current block. Return true 9540b189e4e257924d90aaf63bf2e12bc7bbca961aDan Gohman /// if selection was successful. 9640b189e4e257924d90aaf63bf2e12bc7bbca961aDan Gohman /// 9740b189e4e257924d90aaf63bf2e12bc7bbca961aDan Gohman bool SelectOperator(User *I, unsigned Opcode); 9840b189e4e257924d90aaf63bf2e12bc7bbca961aDan Gohman 9999b218218c0ca3ebfdd568ddfeafa07842e9d69dDan Gohman /// TargetSelectInstruction - This method is called by target-independent 10099b218218c0ca3ebfdd568ddfeafa07842e9d69dDan Gohman /// code when the normal FastISel process fails to select an instruction. 10199b218218c0ca3ebfdd568ddfeafa07842e9d69dDan Gohman /// This gives targets a chance to emit code for anything that doesn't 10299b218218c0ca3ebfdd568ddfeafa07842e9d69dDan Gohman /// fit into FastISel's framework. It returns true if it was successful. 10399b218218c0ca3ebfdd568ddfeafa07842e9d69dDan Gohman /// 10499b218218c0ca3ebfdd568ddfeafa07842e9d69dDan Gohman virtual bool 1053df24e667f04a7003342b534310919abc9c87418Dan Gohman TargetSelectInstruction(Instruction *I) = 0; 1063df24e667f04a7003342b534310919abc9c87418Dan Gohman 1073df24e667f04a7003342b534310919abc9c87418Dan Gohman /// getRegForValue - Create a virtual register and arrange for it to 1083df24e667f04a7003342b534310919abc9c87418Dan Gohman /// be assigned the value for the given LLVM value. 1093df24e667f04a7003342b534310919abc9c87418Dan Gohman unsigned getRegForValue(Value *V); 11099b218218c0ca3ebfdd568ddfeafa07842e9d69dDan Gohman 11159fbc80f6b3b5c71dfb84149f589625f7ed510e3Evan Cheng /// lookUpRegForValue - Look up the value to see if its value is already 11259fbc80f6b3b5c71dfb84149f589625f7ed510e3Evan Cheng /// cached in a register. It may be defined by instructions across blocks or 11359fbc80f6b3b5c71dfb84149f589625f7ed510e3Evan Cheng /// defined locally. 11459fbc80f6b3b5c71dfb84149f589625f7ed510e3Evan Cheng unsigned lookUpRegForValue(Value *V); 11559fbc80f6b3b5c71dfb84149f589625f7ed510e3Evan Cheng 116c8a1a3c426209e9c7b35e279e1578a89edc40af6Dan Gohman /// getRegForGEPIndex - This is a wrapper around getRegForValue that also 117c8a1a3c426209e9c7b35e279e1578a89edc40af6Dan Gohman /// takes care of truncating or sign-extending the given getelementptr 118c8a1a3c426209e9c7b35e279e1578a89edc40af6Dan Gohman /// index value. 119c8a1a3c426209e9c7b35e279e1578a89edc40af6Dan Gohman unsigned getRegForGEPIndex(Value *V); 120c8a1a3c426209e9c7b35e279e1578a89edc40af6Dan Gohman 121cc8430f742b0f1e567292c8a776e94fc1c930b2aDan Gohman virtual ~FastISel(); 122cc8430f742b0f1e567292c8a776e94fc1c930b2aDan Gohman 123b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmanprotected: 1243df24e667f04a7003342b534310919abc9c87418Dan Gohman FastISel(MachineFunction &mf, 125d57dd5f4e6740520820bc0fca42a540e31c27a73Dan Gohman MachineModuleInfo *mmi, 12683489bb7700c69b7a4a8da59365c42d3f5c8129bDevang Patel DwarfWriter *dw, 1273df24e667f04a7003342b534310919abc9c87418Dan Gohman DenseMap<const Value *, unsigned> &vm, 1280586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman DenseMap<const BasicBlock *, MachineBasicBlock *> &bm, 129dd5b58ad7be78be90390074f0df138778af5c895Dan Gohman DenseMap<const AllocaInst *, int> &am 130dd5b58ad7be78be90390074f0df138778af5c895Dan Gohman#ifndef NDEBUG 131dd5b58ad7be78be90390074f0df138778af5c895Dan Gohman , SmallSet<Instruction*, 8> &cil 132dd5b58ad7be78be90390074f0df138778af5c895Dan Gohman#endif 133dd5b58ad7be78be90390074f0df138778af5c895Dan Gohman ); 134e285a74f7cf9dd3ccf4fe758576cf83301f8a43eDan Gohman 135bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// FastEmit_r - This method is called by target-independent code 136bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// to request that an instruction with the given type and opcode 137bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// be emitted. 138b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman virtual unsigned FastEmit_(MVT::SimpleValueType VT, 1390f84e4e31009eecf2dfcbe6113b65d0919f30254Owen Anderson MVT::SimpleValueType RetVT, 140b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman ISD::NodeType Opcode); 141bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman 142bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// FastEmit_r - This method is called by target-independent code 143bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// to request that an instruction with the given type, opcode, and 144bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// register operand be emitted. 145bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// 146b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman virtual unsigned FastEmit_r(MVT::SimpleValueType VT, 1470f84e4e31009eecf2dfcbe6113b65d0919f30254Owen Anderson MVT::SimpleValueType RetVT, 148b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman ISD::NodeType Opcode, unsigned Op0); 149bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman 150bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// FastEmit_rr - This method is called by target-independent code 151bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// to request that an instruction with the given type, opcode, and 152bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// register operands be emitted. 153bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// 154b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman virtual unsigned FastEmit_rr(MVT::SimpleValueType VT, 1550f84e4e31009eecf2dfcbe6113b65d0919f30254Owen Anderson MVT::SimpleValueType RetVT, 156b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman ISD::NodeType Opcode, 157b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman unsigned Op0, unsigned Op1); 158b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman 15983785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng /// FastEmit_ri - This method is called by target-independent code 16083785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng /// to request that an instruction with the given type, opcode, and 16183785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng /// register and immediate operands be emitted. 16283785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng /// 16383785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng virtual unsigned FastEmit_ri(MVT::SimpleValueType VT, 1640f84e4e31009eecf2dfcbe6113b65d0919f30254Owen Anderson MVT::SimpleValueType RetVT, 16583785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng ISD::NodeType Opcode, 166d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman unsigned Op0, uint64_t Imm); 167d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman 16810df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// FastEmit_rf - This method is called by target-independent code 16910df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// to request that an instruction with the given type, opcode, and 17010df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// register and floating-point immediate operands be emitted. 17110df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// 17210df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman virtual unsigned FastEmit_rf(MVT::SimpleValueType VT, 17310df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman MVT::SimpleValueType RetVT, 17410df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman ISD::NodeType Opcode, 17510df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman unsigned Op0, ConstantFP *FPImm); 17610df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman 177d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// FastEmit_rri - This method is called by target-independent code 178d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// to request that an instruction with the given type, opcode, and 179d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// register and immediate operands be emitted. 180d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// 181d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman virtual unsigned FastEmit_rri(MVT::SimpleValueType VT, 1820f84e4e31009eecf2dfcbe6113b65d0919f30254Owen Anderson MVT::SimpleValueType RetVT, 183d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman ISD::NodeType Opcode, 184d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman unsigned Op0, unsigned Op1, uint64_t Imm); 18583785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng 18683785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng /// FastEmit_ri_ - This method is a wrapper of FastEmit_ri. It first tries 18783785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng /// to emit an instruction with an immediate operand using FastEmit_ri. 18883785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng /// If that fails, it materializes the immediate into a register and try 18983785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng /// FastEmit_rr instead. 19083785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng unsigned FastEmit_ri_(MVT::SimpleValueType VT, 19183785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng ISD::NodeType Opcode, 19283785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng unsigned Op0, uint64_t Imm, 19383785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng MVT::SimpleValueType ImmType); 1946d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson 19510df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// FastEmit_rf_ - This method is a wrapper of FastEmit_rf. It first tries 19610df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// to emit an instruction with an immediate operand using FastEmit_rf. 19710df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// If that fails, it materializes the immediate into a register and try 19810df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// FastEmit_rr instead. 19910df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman unsigned FastEmit_rf_(MVT::SimpleValueType VT, 20010df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman ISD::NodeType Opcode, 20110df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman unsigned Op0, ConstantFP *FPImm, 20210df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman MVT::SimpleValueType ImmType); 20310df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman 2046d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson /// FastEmit_i - This method is called by target-independent code 2056d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson /// to request that an instruction with the given type, opcode, and 2066d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson /// immediate operand be emitted. 2076d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson virtual unsigned FastEmit_i(MVT::SimpleValueType VT, 2080f84e4e31009eecf2dfcbe6113b65d0919f30254Owen Anderson MVT::SimpleValueType RetVT, 2096d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson ISD::NodeType Opcode, 2106d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson uint64_t Imm); 21183785c80968165b30fcdd111ceb2c28d38bcff86Evan Cheng 21210df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// FastEmit_f - This method is called by target-independent code 21310df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// to request that an instruction with the given type, opcode, and 21410df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// floating-point immediate operand be emitted. 21510df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman virtual unsigned FastEmit_f(MVT::SimpleValueType VT, 21610df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman MVT::SimpleValueType RetVT, 21710df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman ISD::NodeType Opcode, 21810df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman ConstantFP *FPImm); 21910df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman 220bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// FastEmitInst_ - Emit a MachineInstr with no operands and a 221bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// result register in the given register class. 222bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// 223b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman unsigned FastEmitInst_(unsigned MachineInstOpcode, 224b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman const TargetRegisterClass *RC); 225bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman 226d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// FastEmitInst_r - Emit a MachineInstr with one register operand 227bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// and a result register in the given register class. 228bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// 229b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman unsigned FastEmitInst_r(unsigned MachineInstOpcode, 230b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman const TargetRegisterClass *RC, 231b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman unsigned Op0); 232bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman 233d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// FastEmitInst_rr - Emit a MachineInstr with two register operands 234bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// and a result register in the given register class. 235bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman /// 236b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman unsigned FastEmitInst_rr(unsigned MachineInstOpcode, 237b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman const TargetRegisterClass *RC, 238b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman unsigned Op0, unsigned Op1); 239bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman 240d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// FastEmitInst_ri - Emit a MachineInstr with two register operands 241d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// and a result register in the given register class. 242d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// 243d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman unsigned FastEmitInst_ri(unsigned MachineInstOpcode, 244d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman const TargetRegisterClass *RC, 245d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman unsigned Op0, uint64_t Imm); 246d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman 24710df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// FastEmitInst_rf - Emit a MachineInstr with two register operands 24810df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// and a result register in the given register class. 24910df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman /// 25010df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman unsigned FastEmitInst_rf(unsigned MachineInstOpcode, 25110df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman const TargetRegisterClass *RC, 25210df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman unsigned Op0, ConstantFP *FPImm); 25310df0fa73e396bbc93a8940e8b53827390c54d10Dan Gohman 254d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// FastEmitInst_rri - Emit a MachineInstr with two register operands, 255d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// an immediate, and a result register in the given register class. 256d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman /// 257d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman unsigned FastEmitInst_rri(unsigned MachineInstOpcode, 258d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman const TargetRegisterClass *RC, 259d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman unsigned Op0, unsigned Op1, uint64_t Imm); 2606d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson 2616d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson /// FastEmitInst_i - Emit a MachineInstr with a single immediate 2626d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson /// operand, and a result register in the given register class. 2636d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson unsigned FastEmitInst_i(unsigned MachineInstrOpcode, 2646d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson const TargetRegisterClass *RC, 2656d0c25ec3a7ca822e68f73a4481eee43eb5c9485Owen Anderson uint64_t Imm); 266d5fe57d2f980c6bd1a61450f99c254a76d0f1683Dan Gohman 2678970f00deff00ffce1f35cf00883357e1582daa1Owen Anderson /// FastEmitInst_extractsubreg - Emit a MachineInstr for an extract_subreg 268536ab130ec95cbb7bf30530251dafa7dfecc8471Evan Cheng /// from a specified index of a superregister to a specified type. 269536ab130ec95cbb7bf30530251dafa7dfecc8471Evan Cheng unsigned FastEmitInst_extractsubreg(MVT::SimpleValueType RetVT, 270536ab130ec95cbb7bf30530251dafa7dfecc8471Evan Cheng unsigned Op0, uint32_t Idx); 2718970f00deff00ffce1f35cf00883357e1582daa1Owen Anderson 272d98d6203e429b2d7208b6687931e9079e85e95ecDan Gohman /// FastEmitBranch - Emit an unconditional branch to the given block, 273d98d6203e429b2d7208b6687931e9079e85e95ecDan Gohman /// unless it is the immediate (fall-through) successor, and update 274d98d6203e429b2d7208b6687931e9079e85e95ecDan Gohman /// the CFG. 275d98d6203e429b2d7208b6687931e9079e85e95ecDan Gohman void FastEmitBranch(MachineBasicBlock *MBB); 276d98d6203e429b2d7208b6687931e9079e85e95ecDan Gohman 27795267a1e671efc3c14e916b6978bbb15973b4cdcOwen Anderson void UpdateValueMap(Value* I, unsigned Reg); 278ea09f4f4691a0db65772b54fe8163a48c9dce01dEvan Cheng 279c7f72de3b4ef21828ea4780f0693bf0acd04e1c5Dan Gohman unsigned createResultReg(const TargetRegisterClass *RC); 28095267a1e671efc3c14e916b6978bbb15973b4cdcOwen Anderson 2819c7216f984111eb8f1716741bc9039ed86ec4a9bOwen Anderson /// TargetMaterializeConstant - Emit a constant in a register using 2829c7216f984111eb8f1716741bc9039ed86ec4a9bOwen Anderson /// target-specific logic, such as constant pool loads. 2830586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman virtual unsigned TargetMaterializeConstant(Constant* C) { 2840586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman return 0; 2850586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman } 2860586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman 2870586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman /// TargetMaterializeAlloca - Emit an alloca address in a register using 2880586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman /// target-specific logic. 2890586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman virtual unsigned TargetMaterializeAlloca(AllocaInst* C) { 29095267a1e671efc3c14e916b6978bbb15973b4cdcOwen Anderson return 0; 29195267a1e671efc3c14e916b6978bbb15973b4cdcOwen Anderson } 292c7f72de3b4ef21828ea4780f0693bf0acd04e1c5Dan Gohman 293ea09f4f4691a0db65772b54fe8163a48c9dce01dEvan Chengprivate: 29440b189e4e257924d90aaf63bf2e12bc7bbca961aDan Gohman bool SelectBinaryOp(User *I, ISD::NodeType ISDOpcode); 295bdedd4477331b3b0d28d74658baf05f675f2d195Dan Gohman 29640b189e4e257924d90aaf63bf2e12bc7bbca961aDan Gohman bool SelectGetElementPtr(User *I); 297763d89343be210eb62a13318ca0cc9321ce46bfbDan Gohman 29833134c4a75558288d663267c8991f6bd37a530afDan Gohman bool SelectCall(User *I); 29933134c4a75558288d663267c8991f6bd37a530afDan Gohman 30040b189e4e257924d90aaf63bf2e12bc7bbca961aDan Gohman bool SelectBitCast(User *I); 301d0533c9998d3baf41848ba559a9b2f2c65296d14Owen Anderson 30240b189e4e257924d90aaf63bf2e12bc7bbca961aDan Gohman bool SelectCast(User *I, ISD::NodeType Opcode); 303b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman}; 304b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman 305b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman} 306b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman 307b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman#endif 308