2008-08-13 20:19:35 +00:00
|
|
|
//===-- FastISel.h - Definition of the FastISel class ---------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines the FastISel class.
|
2011-03-11 21:33:55 +00:00
|
|
|
//
|
2008-08-13 20:19:35 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2011-03-11 21:33:55 +00:00
|
|
|
|
2008-08-13 20:19:35 +00:00
|
|
|
#ifndef LLVM_CODEGEN_FASTISEL_H
|
|
|
|
#define LLVM_CODEGEN_FASTISEL_H
|
|
|
|
|
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2010-07-10 09:00:22 +00:00
|
|
|
#include "llvm/CodeGen/MachineBasicBlock.h"
|
2012-12-03 17:02:12 +00:00
|
|
|
#include "llvm/CodeGen/ValueTypes.h"
|
2008-08-13 20:19:35 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2008-09-10 20:11:02 +00:00
|
|
|
class AllocaInst;
|
2011-11-14 17:45:03 +00:00
|
|
|
class Constant;
|
2008-08-27 01:09:54 +00:00
|
|
|
class ConstantFP;
|
2010-07-07 16:29:44 +00:00
|
|
|
class FunctionLoweringInfo;
|
2008-10-14 23:54:11 +00:00
|
|
|
class Instruction;
|
2011-11-14 17:45:03 +00:00
|
|
|
class LoadInst;
|
2008-08-13 20:19:35 +00:00
|
|
|
class MachineBasicBlock;
|
2008-09-05 00:06:23 +00:00
|
|
|
class MachineConstantPool;
|
2008-08-13 20:19:35 +00:00
|
|
|
class MachineFunction;
|
2010-04-22 20:46:50 +00:00
|
|
|
class MachineInstr;
|
2008-09-10 20:11:02 +00:00
|
|
|
class MachineFrameInfo;
|
2008-08-20 21:05:57 +00:00
|
|
|
class MachineRegisterInfo;
|
2012-10-08 16:38:25 +00:00
|
|
|
class DataLayout;
|
2008-08-13 20:19:35 +00:00
|
|
|
class TargetInstrInfo;
|
2012-08-03 04:06:28 +00:00
|
|
|
class TargetLibraryInfo;
|
2008-08-20 22:45:34 +00:00
|
|
|
class TargetLowering;
|
2008-08-22 00:20:26 +00:00
|
|
|
class TargetMachine;
|
2008-08-13 20:19:35 +00:00
|
|
|
class TargetRegisterClass;
|
2010-06-18 23:28:01 +00:00
|
|
|
class TargetRegisterInfo;
|
2011-11-14 17:45:03 +00:00
|
|
|
class User;
|
|
|
|
class Value;
|
2008-08-13 20:19:35 +00:00
|
|
|
|
2008-08-18 23:41:46 +00:00
|
|
|
/// FastISel - This is a fast-path instruction selection class that
|
|
|
|
/// generates poor code and doesn't support illegal types or non-trivial
|
|
|
|
/// lowering, but runs quickly.
|
2008-08-13 20:19:35 +00:00
|
|
|
class FastISel {
|
2008-08-22 00:20:26 +00:00
|
|
|
protected:
|
2008-09-03 23:32:19 +00:00
|
|
|
DenseMap<const Value *, unsigned> LocalValueMap;
|
2010-07-07 16:29:44 +00:00
|
|
|
FunctionLoweringInfo &FuncInfo;
|
2008-08-20 21:05:57 +00:00
|
|
|
MachineRegisterInfo &MRI;
|
2008-09-10 20:11:02 +00:00
|
|
|
MachineFrameInfo &MFI;
|
|
|
|
MachineConstantPool &MCP;
|
2009-02-03 00:55:04 +00:00
|
|
|
DebugLoc DL;
|
2008-08-22 00:20:26 +00:00
|
|
|
const TargetMachine &TM;
|
2012-10-08 16:38:25 +00:00
|
|
|
const DataLayout &TD;
|
2008-08-20 21:05:57 +00:00
|
|
|
const TargetInstrInfo &TII;
|
2008-08-22 00:20:26 +00:00
|
|
|
const TargetLowering &TLI;
|
2010-06-18 23:28:01 +00:00
|
|
|
const TargetRegisterInfo &TRI;
|
2012-08-03 04:06:28 +00:00
|
|
|
const TargetLibraryInfo *LibInfo;
|
2011-08-18 22:06:10 +00:00
|
|
|
|
|
|
|
/// The position of the last instruction for materializing constants
|
|
|
|
/// for use in the current block. It resets to EmitStartPt when it
|
|
|
|
/// makes sense (for example, it's usually profitable to avoid function
|
|
|
|
/// calls between the definition and the use)
|
2010-07-10 09:00:22 +00:00
|
|
|
MachineInstr *LastLocalValue;
|
2008-08-13 20:19:35 +00:00
|
|
|
|
2011-08-18 22:06:10 +00:00
|
|
|
/// The top most instruction in the current block that is allowed for
|
|
|
|
/// emitting local variables. LastLocalValue resets to EmitStartPt when
|
|
|
|
/// it makes sense (for example, on function calls)
|
|
|
|
MachineInstr *EmitStartPt;
|
|
|
|
|
2008-08-13 20:19:35 +00:00
|
|
|
public:
|
2010-07-10 09:00:22 +00:00
|
|
|
/// getLastLocalValue - Return the position of the last instruction
|
|
|
|
/// emitted for materializing constants for use in the current block.
|
|
|
|
MachineInstr *getLastLocalValue() { return LastLocalValue; }
|
|
|
|
|
|
|
|
/// setLastLocalValue - Update the position of the last instruction
|
|
|
|
/// emitted for materializing constants for use in the current block.
|
2011-08-18 22:06:10 +00:00
|
|
|
void setLastLocalValue(MachineInstr *I) {
|
|
|
|
EmitStartPt = I;
|
|
|
|
LastLocalValue = I;
|
|
|
|
}
|
2010-07-10 09:00:22 +00:00
|
|
|
|
2009-02-03 00:55:04 +00:00
|
|
|
/// startNewBlock - Set the current block to which generated machine
|
|
|
|
/// instructions will be appended, and clear the local CSE map.
|
2008-10-04 00:56:36 +00:00
|
|
|
///
|
2010-07-10 09:00:22 +00:00
|
|
|
void startNewBlock();
|
2008-10-04 00:56:36 +00:00
|
|
|
|
2009-04-16 01:33:10 +00:00
|
|
|
/// getCurDebugLoc() - Return current debug location information.
|
|
|
|
DebugLoc getCurDebugLoc() const { return DL; }
|
2013-02-11 01:27:15 +00:00
|
|
|
|
|
|
|
/// LowerArguments - Do "fast" instruction selection for function arguments
|
|
|
|
/// and append machine instructions to the current block. Return true if
|
|
|
|
/// it is successful.
|
|
|
|
bool LowerArguments();
|
2009-04-16 01:33:10 +00:00
|
|
|
|
2008-09-03 23:12:08 +00:00
|
|
|
/// SelectInstruction - Do "fast" instruction selection for the given
|
|
|
|
/// LLVM IR instruction, and append generated machine instructions to
|
|
|
|
/// the current block. Return true if selection was successful.
|
|
|
|
///
|
2010-04-15 01:51:59 +00:00
|
|
|
bool SelectInstruction(const Instruction *I);
|
2008-08-13 20:19:35 +00:00
|
|
|
|
2009-10-05 15:23:17 +00:00
|
|
|
/// SelectOperator - Do "fast" instruction selection for the given
|
2008-09-05 18:18:20 +00:00
|
|
|
/// LLVM IR operator (Instruction or ConstantExpr), and append
|
|
|
|
/// generated machine instructions to the current block. Return true
|
|
|
|
/// if selection was successful.
|
|
|
|
///
|
2010-04-15 01:51:59 +00:00
|
|
|
bool SelectOperator(const User *I, unsigned Opcode);
|
2008-09-05 18:18:20 +00:00
|
|
|
|
2008-09-03 23:12:08 +00:00
|
|
|
/// getRegForValue - Create a virtual register and arrange for it to
|
|
|
|
/// be assigned the value for the given LLVM value.
|
2010-04-15 01:51:59 +00:00
|
|
|
unsigned getRegForValue(const Value *V);
|
2008-08-28 23:21:34 +00:00
|
|
|
|
2008-09-09 01:26:59 +00:00
|
|
|
/// lookUpRegForValue - Look up the value to see if its value is already
|
|
|
|
/// cached in a register. It may be defined by instructions across blocks or
|
|
|
|
/// defined locally.
|
2010-04-15 01:51:59 +00:00
|
|
|
unsigned lookUpRegForValue(const Value *V);
|
2008-09-09 01:26:59 +00:00
|
|
|
|
2008-12-08 07:57:47 +00:00
|
|
|
/// getRegForGEPIndex - This is a wrapper around getRegForValue that also
|
|
|
|
/// takes care of truncating or sign-extending the given getelementptr
|
|
|
|
/// index value.
|
2010-05-11 23:54:07 +00:00
|
|
|
std::pair<unsigned, bool> getRegForGEPIndex(const Value *V);
|
2008-12-08 07:57:47 +00:00
|
|
|
|
2013-04-19 22:29:18 +00:00
|
|
|
/// \brief We're checking to see if we can fold \p LI the \p FoldInst.
|
|
|
|
/// Note that we could have a sequence where multiple LLVM IR instructions
|
|
|
|
/// are folded into the same machineinstr. For example we could have:
|
|
|
|
/// A: x = load i32 *P
|
|
|
|
/// B: y = icmp A, 42
|
|
|
|
/// C: br y, ...
|
|
|
|
///
|
|
|
|
/// In this scenario, \p LI is "A", and \p FoldInst is "C". We know
|
|
|
|
/// about "B" (and any other folded instructions) because it is between
|
|
|
|
/// A and C.
|
|
|
|
///
|
|
|
|
/// If we succeed folding, return true.
|
|
|
|
///
|
|
|
|
bool tryToFoldLoad(const LoadInst *LI, const Instruction *FoldInst);
|
|
|
|
|
|
|
|
/// \brief The specified machine instr operand is a vreg, and that
|
implement rdar://6653118 - fastisel should fold loads where possible.
Since mem2reg isn't run at -O0, we get a ton of reloads from the stack,
for example, before, this code:
int foo(int x, int y, int z) {
return x+y+z;
}
used to compile into:
_foo: ## @foo
subq $12, %rsp
movl %edi, 8(%rsp)
movl %esi, 4(%rsp)
movl %edx, (%rsp)
movl 8(%rsp), %edx
movl 4(%rsp), %esi
addl %edx, %esi
movl (%rsp), %edx
addl %esi, %edx
movl %edx, %eax
addq $12, %rsp
ret
Now we produce:
_foo: ## @foo
subq $12, %rsp
movl %edi, 8(%rsp)
movl %esi, 4(%rsp)
movl %edx, (%rsp)
movl 8(%rsp), %edx
addl 4(%rsp), %edx ## Folded load
addl (%rsp), %edx ## Folded load
movl %edx, %eax
addq $12, %rsp
ret
Fewer instructions and less register use = faster compiles.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113102 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-05 02:18:34 +00:00
|
|
|
/// vreg is being provided by the specified load instruction. If possible,
|
|
|
|
/// try to fold the load as an operand to the instruction, returning true if
|
|
|
|
/// possible.
|
2013-04-19 22:29:18 +00:00
|
|
|
/// This method should be implemented by targets.
|
|
|
|
virtual bool tryToFoldLoadIntoMI(MachineInstr * /*MI*/, unsigned /*OpNo*/,
|
|
|
|
const LoadInst * /*LI*/) {
|
implement rdar://6653118 - fastisel should fold loads where possible.
Since mem2reg isn't run at -O0, we get a ton of reloads from the stack,
for example, before, this code:
int foo(int x, int y, int z) {
return x+y+z;
}
used to compile into:
_foo: ## @foo
subq $12, %rsp
movl %edi, 8(%rsp)
movl %esi, 4(%rsp)
movl %edx, (%rsp)
movl 8(%rsp), %edx
movl 4(%rsp), %esi
addl %edx, %esi
movl (%rsp), %edx
addl %esi, %edx
movl %edx, %eax
addq $12, %rsp
ret
Now we produce:
_foo: ## @foo
subq $12, %rsp
movl %edi, 8(%rsp)
movl %esi, 4(%rsp)
movl %edx, (%rsp)
movl 8(%rsp), %edx
addl 4(%rsp), %edx ## Folded load
addl (%rsp), %edx ## Folded load
movl %edx, %eax
addq $12, %rsp
ret
Fewer instructions and less register use = faster compiles.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113102 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-05 02:18:34 +00:00
|
|
|
return false;
|
|
|
|
}
|
2011-03-11 21:33:55 +00:00
|
|
|
|
implement rdar://6653118 - fastisel should fold loads where possible.
Since mem2reg isn't run at -O0, we get a ton of reloads from the stack,
for example, before, this code:
int foo(int x, int y, int z) {
return x+y+z;
}
used to compile into:
_foo: ## @foo
subq $12, %rsp
movl %edi, 8(%rsp)
movl %esi, 4(%rsp)
movl %edx, (%rsp)
movl 8(%rsp), %edx
movl 4(%rsp), %esi
addl %edx, %esi
movl (%rsp), %edx
addl %esi, %edx
movl %edx, %eax
addq $12, %rsp
ret
Now we produce:
_foo: ## @foo
subq $12, %rsp
movl %edi, 8(%rsp)
movl %esi, 4(%rsp)
movl %edx, (%rsp)
movl 8(%rsp), %edx
addl 4(%rsp), %edx ## Folded load
addl (%rsp), %edx ## Folded load
movl %edx, %eax
addq $12, %rsp
ret
Fewer instructions and less register use = faster compiles.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113102 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-05 02:18:34 +00:00
|
|
|
/// recomputeInsertPt - Reset InsertPt to prepare for inserting instructions
|
2010-07-10 09:00:22 +00:00
|
|
|
/// into the current block.
|
|
|
|
void recomputeInsertPt();
|
|
|
|
|
2012-12-11 00:18:02 +00:00
|
|
|
/// removeDeadCode - Remove all dead instructions between the I and E.
|
|
|
|
void removeDeadCode(MachineBasicBlock::iterator I,
|
|
|
|
MachineBasicBlock::iterator E);
|
|
|
|
|
2012-10-03 08:10:01 +00:00
|
|
|
struct SavePoint {
|
|
|
|
MachineBasicBlock::iterator InsertPt;
|
|
|
|
DebugLoc DL;
|
|
|
|
};
|
|
|
|
|
2010-07-10 09:00:22 +00:00
|
|
|
/// enterLocalValueArea - Prepare InsertPt to begin inserting instructions
|
|
|
|
/// into the local value area and return the old insert position.
|
2012-10-03 08:10:01 +00:00
|
|
|
SavePoint enterLocalValueArea();
|
2010-07-10 09:00:22 +00:00
|
|
|
|
2010-07-14 01:07:44 +00:00
|
|
|
/// leaveLocalValueArea - Reset InsertPt to the given old insert position.
|
2012-10-03 08:10:01 +00:00
|
|
|
void leaveLocalValueArea(SavePoint Old);
|
2010-07-10 09:00:22 +00:00
|
|
|
|
2008-08-20 00:56:17 +00:00
|
|
|
virtual ~FastISel();
|
|
|
|
|
2008-08-13 20:19:35 +00:00
|
|
|
protected:
|
2012-08-03 04:06:28 +00:00
|
|
|
explicit FastISel(FunctionLoweringInfo &funcInfo,
|
|
|
|
const TargetLibraryInfo *libInfo);
|
2008-08-14 21:51:29 +00:00
|
|
|
|
2009-12-05 01:27:58 +00:00
|
|
|
/// TargetSelectInstruction - This method is called by target-independent
|
|
|
|
/// code when the normal FastISel process fails to select an instruction.
|
|
|
|
/// This gives targets a chance to emit code for anything that doesn't
|
|
|
|
/// fit into FastISel's framework. It returns true if it was successful.
|
|
|
|
///
|
|
|
|
virtual bool
|
2010-04-15 01:51:59 +00:00
|
|
|
TargetSelectInstruction(const Instruction *I) = 0;
|
2013-02-11 01:27:15 +00:00
|
|
|
|
|
|
|
/// FastLowerArguments - This method is called by target-independent code to
|
|
|
|
/// do target specific argument lowering. It returns true if it was
|
|
|
|
/// successful.
|
|
|
|
virtual bool FastLowerArguments();
|
2009-12-05 01:27:58 +00:00
|
|
|
|
2008-08-20 00:11:48 +00:00
|
|
|
/// FastEmit_r - This method is called by target-independent code
|
|
|
|
/// to request that an instruction with the given type and opcode
|
|
|
|
/// be emitted.
|
2009-08-11 20:47:22 +00:00
|
|
|
virtual unsigned FastEmit_(MVT VT,
|
|
|
|
MVT RetVT,
|
2010-01-05 22:26:32 +00:00
|
|
|
unsigned Opcode);
|
2008-08-20 00:11:48 +00:00
|
|
|
|
|
|
|
/// FastEmit_r - This method is called by target-independent code
|
|
|
|
/// to request that an instruction with the given type, opcode, and
|
|
|
|
/// register operand be emitted.
|
|
|
|
///
|
2009-08-11 20:47:22 +00:00
|
|
|
virtual unsigned FastEmit_r(MVT VT,
|
|
|
|
MVT RetVT,
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned Opcode,
|
|
|
|
unsigned Op0, bool Op0IsKill);
|
2008-08-20 00:11:48 +00:00
|
|
|
|
|
|
|
/// FastEmit_rr - This method is called by target-independent code
|
|
|
|
/// to request that an instruction with the given type, opcode, and
|
|
|
|
/// register operands be emitted.
|
|
|
|
///
|
2009-08-11 20:47:22 +00:00
|
|
|
virtual unsigned FastEmit_rr(MVT VT,
|
|
|
|
MVT RetVT,
|
2010-01-05 22:26:32 +00:00
|
|
|
unsigned Opcode,
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned Op0, bool Op0IsKill,
|
|
|
|
unsigned Op1, bool Op1IsKill);
|
2008-08-13 20:19:35 +00:00
|
|
|
|
2008-08-20 22:45:34 +00:00
|
|
|
/// FastEmit_ri - This method is called by target-independent code
|
|
|
|
/// to request that an instruction with the given type, opcode, and
|
|
|
|
/// register and immediate operands be emitted.
|
|
|
|
///
|
2009-08-11 20:47:22 +00:00
|
|
|
virtual unsigned FastEmit_ri(MVT VT,
|
|
|
|
MVT RetVT,
|
2010-01-05 22:26:32 +00:00
|
|
|
unsigned Opcode,
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned Op0, bool Op0IsKill,
|
|
|
|
uint64_t Imm);
|
2008-08-21 01:41:07 +00:00
|
|
|
|
2008-08-27 01:09:54 +00:00
|
|
|
/// FastEmit_rf - This method is called by target-independent code
|
|
|
|
/// to request that an instruction with the given type, opcode, and
|
|
|
|
/// register and floating-point immediate operands be emitted.
|
|
|
|
///
|
2009-08-11 20:47:22 +00:00
|
|
|
virtual unsigned FastEmit_rf(MVT VT,
|
|
|
|
MVT RetVT,
|
2010-01-05 22:26:32 +00:00
|
|
|
unsigned Opcode,
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned Op0, bool Op0IsKill,
|
|
|
|
const ConstantFP *FPImm);
|
2008-08-27 01:09:54 +00:00
|
|
|
|
2008-08-21 01:41:07 +00:00
|
|
|
/// FastEmit_rri - This method is called by target-independent code
|
|
|
|
/// to request that an instruction with the given type, opcode, and
|
|
|
|
/// register and immediate operands be emitted.
|
|
|
|
///
|
2009-08-11 20:47:22 +00:00
|
|
|
virtual unsigned FastEmit_rri(MVT VT,
|
|
|
|
MVT RetVT,
|
2010-01-05 22:26:32 +00:00
|
|
|
unsigned Opcode,
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned Op0, bool Op0IsKill,
|
|
|
|
unsigned Op1, bool Op1IsKill,
|
|
|
|
uint64_t Imm);
|
2008-08-20 22:45:34 +00:00
|
|
|
|
|
|
|
/// FastEmit_ri_ - This method is a wrapper of FastEmit_ri. It first tries
|
|
|
|
/// to emit an instruction with an immediate operand using FastEmit_ri.
|
|
|
|
/// If that fails, it materializes the immediate into a register and try
|
|
|
|
/// FastEmit_rr instead.
|
2009-08-11 20:47:22 +00:00
|
|
|
unsigned FastEmit_ri_(MVT VT,
|
2010-01-05 22:26:32 +00:00
|
|
|
unsigned Opcode,
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned Op0, bool Op0IsKill,
|
|
|
|
uint64_t Imm, MVT ImmType);
|
2011-03-11 21:33:55 +00:00
|
|
|
|
2008-08-25 20:20:32 +00:00
|
|
|
/// FastEmit_i - This method is called by target-independent code
|
|
|
|
/// to request that an instruction with the given type, opcode, and
|
|
|
|
/// immediate operand be emitted.
|
2009-08-11 20:47:22 +00:00
|
|
|
virtual unsigned FastEmit_i(MVT VT,
|
|
|
|
MVT RetVT,
|
2010-01-05 22:26:32 +00:00
|
|
|
unsigned Opcode,
|
2008-08-25 20:20:32 +00:00
|
|
|
uint64_t Imm);
|
2008-08-20 22:45:34 +00:00
|
|
|
|
2008-08-27 01:09:54 +00:00
|
|
|
/// FastEmit_f - This method is called by target-independent code
|
|
|
|
/// to request that an instruction with the given type, opcode, and
|
|
|
|
/// floating-point immediate operand be emitted.
|
2009-08-11 20:47:22 +00:00
|
|
|
virtual unsigned FastEmit_f(MVT VT,
|
|
|
|
MVT RetVT,
|
2010-01-05 22:26:32 +00:00
|
|
|
unsigned Opcode,
|
2010-04-15 01:51:59 +00:00
|
|
|
const ConstantFP *FPImm);
|
2008-08-27 01:09:54 +00:00
|
|
|
|
2008-08-20 00:11:48 +00:00
|
|
|
/// FastEmitInst_ - Emit a MachineInstr with no operands and a
|
|
|
|
/// result register in the given register class.
|
|
|
|
///
|
2008-08-13 20:19:35 +00:00
|
|
|
unsigned FastEmitInst_(unsigned MachineInstOpcode,
|
|
|
|
const TargetRegisterClass *RC);
|
2008-08-20 00:11:48 +00:00
|
|
|
|
2008-08-21 01:41:07 +00:00
|
|
|
/// FastEmitInst_r - Emit a MachineInstr with one register operand
|
2008-08-20 00:11:48 +00:00
|
|
|
/// and a result register in the given register class.
|
|
|
|
///
|
2008-08-13 20:19:35 +00:00
|
|
|
unsigned FastEmitInst_r(unsigned MachineInstOpcode,
|
|
|
|
const TargetRegisterClass *RC,
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned Op0, bool Op0IsKill);
|
2008-08-20 00:11:48 +00:00
|
|
|
|
2008-08-21 01:41:07 +00:00
|
|
|
/// FastEmitInst_rr - Emit a MachineInstr with two register operands
|
2008-08-20 00:11:48 +00:00
|
|
|
/// and a result register in the given register class.
|
|
|
|
///
|
2008-08-13 20:19:35 +00:00
|
|
|
unsigned FastEmitInst_rr(unsigned MachineInstOpcode,
|
|
|
|
const TargetRegisterClass *RC,
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned Op0, bool Op0IsKill,
|
|
|
|
unsigned Op1, bool Op1IsKill);
|
2008-08-20 00:11:48 +00:00
|
|
|
|
2011-05-05 17:59:04 +00:00
|
|
|
/// FastEmitInst_rrr - Emit a MachineInstr with three register operands
|
|
|
|
/// and a result register in the given register class.
|
|
|
|
///
|
|
|
|
unsigned FastEmitInst_rrr(unsigned MachineInstOpcode,
|
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
unsigned Op0, bool Op0IsKill,
|
|
|
|
unsigned Op1, bool Op1IsKill,
|
|
|
|
unsigned Op2, bool Op2IsKill);
|
|
|
|
|
2011-04-22 23:08:45 +00:00
|
|
|
/// FastEmitInst_ri - Emit a MachineInstr with a register operand,
|
|
|
|
/// an immediate, and a result register in the given register class.
|
2008-08-21 01:41:07 +00:00
|
|
|
///
|
|
|
|
unsigned FastEmitInst_ri(unsigned MachineInstOpcode,
|
|
|
|
const TargetRegisterClass *RC,
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned Op0, bool Op0IsKill,
|
|
|
|
uint64_t Imm);
|
2008-08-21 01:41:07 +00:00
|
|
|
|
2011-03-11 21:33:55 +00:00
|
|
|
/// FastEmitInst_rii - Emit a MachineInstr with one register operand
|
|
|
|
/// and two immediate operands.
|
|
|
|
///
|
|
|
|
unsigned FastEmitInst_rii(unsigned MachineInstOpcode,
|
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
unsigned Op0, bool Op0IsKill,
|
|
|
|
uint64_t Imm1, uint64_t Imm2);
|
|
|
|
|
2008-08-27 01:09:54 +00:00
|
|
|
/// FastEmitInst_rf - Emit a MachineInstr with two register operands
|
|
|
|
/// and a result register in the given register class.
|
|
|
|
///
|
|
|
|
unsigned FastEmitInst_rf(unsigned MachineInstOpcode,
|
|
|
|
const TargetRegisterClass *RC,
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned Op0, bool Op0IsKill,
|
|
|
|
const ConstantFP *FPImm);
|
2008-08-27 01:09:54 +00:00
|
|
|
|
2008-08-21 01:41:07 +00:00
|
|
|
/// FastEmitInst_rri - Emit a MachineInstr with two register operands,
|
|
|
|
/// an immediate, and a result register in the given register class.
|
|
|
|
///
|
|
|
|
unsigned FastEmitInst_rri(unsigned MachineInstOpcode,
|
|
|
|
const TargetRegisterClass *RC,
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned Op0, bool Op0IsKill,
|
|
|
|
unsigned Op1, bool Op1IsKill,
|
|
|
|
uint64_t Imm);
|
2011-03-11 21:33:55 +00:00
|
|
|
|
2012-06-01 19:33:18 +00:00
|
|
|
/// FastEmitInst_rrii - Emit a MachineInstr with two register operands,
|
|
|
|
/// two immediates operands, and a result register in the given register
|
|
|
|
/// class.
|
|
|
|
unsigned FastEmitInst_rrii(unsigned MachineInstOpcode,
|
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
unsigned Op0, bool Op0IsKill,
|
|
|
|
unsigned Op1, bool Op1IsKill,
|
|
|
|
uint64_t Imm1, uint64_t Imm2);
|
|
|
|
|
2008-08-25 20:20:32 +00:00
|
|
|
/// FastEmitInst_i - Emit a MachineInstr with a single immediate
|
|
|
|
/// operand, and a result register in the given register class.
|
|
|
|
unsigned FastEmitInst_i(unsigned MachineInstrOpcode,
|
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
uint64_t Imm);
|
2011-04-22 23:38:06 +00:00
|
|
|
|
|
|
|
/// FastEmitInst_ii - Emit a MachineInstr with a two immediate operands.
|
|
|
|
unsigned FastEmitInst_ii(unsigned MachineInstrOpcode,
|
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
uint64_t Imm1, uint64_t Imm2);
|
|
|
|
|
2008-08-27 22:30:02 +00:00
|
|
|
/// FastEmitInst_extractsubreg - Emit a MachineInstr for an extract_subreg
|
2009-01-22 09:10:11 +00:00
|
|
|
/// from a specified index of a superregister to a specified type.
|
2009-08-11 20:47:22 +00:00
|
|
|
unsigned FastEmitInst_extractsubreg(MVT RetVT,
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned Op0, bool Op0IsKill,
|
|
|
|
uint32_t Idx);
|
2008-08-27 22:30:02 +00:00
|
|
|
|
2009-03-13 20:42:20 +00:00
|
|
|
/// FastEmitZExtFromI1 - Emit MachineInstrs to compute the value of Op
|
|
|
|
/// with all but the least significant bit set to zero.
|
2009-08-11 20:47:22 +00:00
|
|
|
unsigned FastEmitZExtFromI1(MVT VT,
|
2010-05-11 23:54:07 +00:00
|
|
|
unsigned Op0, bool Op0IsKill);
|
2009-03-13 20:42:20 +00:00
|
|
|
|
2008-10-02 22:15:21 +00:00
|
|
|
/// FastEmitBranch - Emit an unconditional branch to the given block,
|
|
|
|
/// unless it is the immediate (fall-through) successor, and update
|
|
|
|
/// the CFG.
|
2010-06-17 22:43:56 +00:00
|
|
|
void FastEmitBranch(MachineBasicBlock *MBB, DebugLoc DL);
|
2008-10-02 22:15:21 +00:00
|
|
|
|
2011-05-16 21:06:17 +00:00
|
|
|
void UpdateValueMap(const Value* I, unsigned Reg, unsigned NumRegs = 1);
|
2008-09-03 06:43:10 +00:00
|
|
|
|
2008-08-21 00:19:05 +00:00
|
|
|
unsigned createResultReg(const TargetRegisterClass *RC);
|
2011-03-11 21:33:55 +00:00
|
|
|
|
|
|
|
/// TargetMaterializeConstant - Emit a constant in a register using
|
2008-09-05 20:49:33 +00:00
|
|
|
/// target-specific logic, such as constant pool loads.
|
2010-04-15 01:51:59 +00:00
|
|
|
virtual unsigned TargetMaterializeConstant(const Constant* C) {
|
2008-09-10 20:11:02 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// TargetMaterializeAlloca - Emit an alloca address in a register using
|
|
|
|
/// target-specific logic.
|
2010-04-15 01:51:59 +00:00
|
|
|
virtual unsigned TargetMaterializeAlloca(const AllocaInst* C) {
|
2008-09-05 00:06:23 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2008-08-21 00:19:05 +00:00
|
|
|
|
2011-04-27 22:41:55 +00:00
|
|
|
virtual unsigned TargetMaterializeFloatZero(const ConstantFP* CF) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-09-03 06:43:10 +00:00
|
|
|
private:
|
2010-04-15 01:51:59 +00:00
|
|
|
bool SelectBinaryOp(const User *I, unsigned ISDOpcode);
|
2008-08-20 00:11:48 +00:00
|
|
|
|
2010-04-15 01:51:59 +00:00
|
|
|
bool SelectFNeg(const User *I);
|
2009-09-03 22:53:57 +00:00
|
|
|
|
2010-04-15 01:51:59 +00:00
|
|
|
bool SelectGetElementPtr(const User *I);
|
2008-08-26 21:28:54 +00:00
|
|
|
|
2010-04-15 01:51:59 +00:00
|
|
|
bool SelectCall(const User *I);
|
2008-09-25 17:05:24 +00:00
|
|
|
|
2010-04-15 01:51:59 +00:00
|
|
|
bool SelectBitCast(const User *I);
|
2011-03-11 21:33:55 +00:00
|
|
|
|
2010-04-15 01:51:59 +00:00
|
|
|
bool SelectCast(const User *I, unsigned Opcode);
|
2010-04-23 15:29:50 +00:00
|
|
|
|
2011-05-16 20:27:46 +00:00
|
|
|
bool SelectExtractValue(const User *I);
|
|
|
|
|
2011-12-09 20:09:54 +00:00
|
|
|
bool SelectInsertValue(const User *I);
|
|
|
|
|
2010-04-23 15:29:50 +00:00
|
|
|
/// HandlePHINodesInSuccessorBlocks - Handle PHI nodes in successor blocks.
|
|
|
|
/// Emit code to ensure constants are copied into registers when needed.
|
|
|
|
/// Remember the virtual registers that need to be added to the Machine PHI
|
|
|
|
/// nodes as input. We cannot just directly add them, because expansion
|
|
|
|
/// might result in multiple MBB's for one BB. As such, the start of the
|
|
|
|
/// BB might correspond to a different MBB than the end.
|
|
|
|
bool HandlePHINodesInSuccessorBlocks(const BasicBlock *LLVMBB);
|
2010-05-03 23:36:34 +00:00
|
|
|
|
|
|
|
/// materializeRegForValue - Helper for getRegForVale. This function is
|
|
|
|
/// called when the value isn't already available in a register and must
|
|
|
|
/// be materialized with new instructions.
|
|
|
|
unsigned materializeRegForValue(const Value *V, MVT VT);
|
2010-05-11 23:54:07 +00:00
|
|
|
|
2011-08-18 22:06:10 +00:00
|
|
|
/// flushLocalValueMap - clears LocalValueMap and moves the area for the
|
|
|
|
/// new local variables to the beginning of the block. It helps to avoid
|
|
|
|
/// spilling cached variables across heavy instructions like calls.
|
|
|
|
void flushLocalValueMap();
|
|
|
|
|
2010-05-11 23:54:07 +00:00
|
|
|
/// hasTrivialKill - Test whether the given value has exactly one use.
|
|
|
|
bool hasTrivialKill(const Value *V) const;
|
2008-08-13 20:19:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|