1 //===-- AMDILISelLowering.h - AMDIL DAG Lowering Interface ------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //==-----------------------------------------------------------------------===//
10 // This file defines the interfaces that AMDIL uses to lower LLVM code into a
13 //===----------------------------------------------------------------------===//
15 #ifndef AMDIL_ISELLOWERING_H_
16 #define AMDIL_ISELLOWERING_H_
18 #include "llvm/CodeGen/CallingConvLower.h"
19 #include "llvm/CodeGen/MachineInstrBuilder.h"
20 #include "llvm/CodeGen/SelectionDAG.h"
21 #include "llvm/Target/TargetLowering.h"
29 FIRST_NUMBER
= ISD::BUILTIN_OP_END
,
30 INTTOANY
, // Dummy instruction that takes an int and goes to
31 // any type converts the SDNode to an int
32 DP_TO_FP
, // Conversion from 64bit FP to 32bit FP
33 FP_TO_DP
, // Conversion from 32bit FP to 64bit FP
34 BITCONV
, // instruction that converts from any type to any type
35 CMOV
, // 32bit FP Conditional move instruction
36 CMOVLOG
, // 32bit FP Conditional move logical instruction
37 SELECT
, // 32bit FP Conditional move logical instruction
38 SETCC
, // 32bit FP Conditional move logical instruction
39 ISGN
, // 32bit Int Sign instruction
40 INEGATE
, // 32bit Int Negation instruction
41 MAD
, // 32bit Fused Multiply Add instruction
42 ADD
, // 32/64 bit pseudo instruction
43 AND
, // 128 bit and instruction
44 OR
, // 128 bit or instruction
45 NOT
, // 128 bit not instruction
46 XOR
, // 128 bit xor instruction
47 MOVE
, // generic mov instruction
48 PHIMOVE
, // generic phi-node mov instruction
49 VBUILD
, // scalar to vector mov instruction
50 VEXTRACT
, // extract vector components
51 VINSERT
, // insert vector components
52 VCONCAT
, // concat a single vector to another vector
53 UMAD
, // 32bit UInt Fused Multiply Add instruction
54 CALL
, // Function call based on a single integer
55 RET
, // Return from a function call
56 SELECT_CC
, // Select the correct conditional instruction
57 BRCC
, // Select the correct branch instruction
58 CMPCC
, // Compare to GPR operands
59 CMPICC
, // Compare two GPR operands, set icc.
60 CMPFCC
, // Compare two FP operands, set fcc.
61 BRICC
, // Branch to dest on icc condition
62 BRFCC
, // Branch to dest on fcc condition
63 SELECT_ICC
, // Select between two values using the current ICC
65 SELECT_FCC
, // Select between two values using the current FCC
67 LCREATE
, // Create a 64bit integer from two 32 bit integers
68 LCOMPHI
, // Get the hi 32 bits from a 64 bit integer
69 LCOMPLO
, // Get the lo 32 bits from a 64 bit integer
70 DCREATE
, // Create a 64bit float from two 32 bit integers
71 DCOMPHI
, // Get the hi 32 bits from a 64 bit float
72 DCOMPLO
, // Get the lo 32 bits from a 64 bit float
73 LCREATE2
, // Create a 64bit integer from two 32 bit integers
74 LCOMPHI2
, // Get the hi 32 bits from a 64 bit integer
75 LCOMPLO2
, // Get the lo 32 bits from a 64 bit integer
76 DCREATE2
, // Create a 64bit float from two 32 bit integers
77 DCOMPHI2
, // Get the hi 32 bits from a 64 bit float
78 DCOMPLO2
, // Get the lo 32 bits from a 64 bit float
79 UMUL
, // 32bit unsigned multiplication
80 IFFB_HI
, // 32bit find first hi bit instruction
81 IFFB_LO
, // 32bit find first low bit instruction
82 DIV_INF
, // Divide with infinity returned on zero divisor
83 SMAX
, // Signed integer max
99 ATOM_G_ADD
= ISD::FIRST_TARGET_MEMORY_OPCODE
,
115 ATOM_G_CMPXCHG_NORET
,
145 ATOM_L_CMPXCHG_NORET
,
176 ATOM_R_CMPXCHG_NORET
,
193 APPEND_CONSUME_NORET
,
209 class MachineBasicBlock
;
212 class TargetInstrInfo
;
214 class AMDILTargetLowering
: public TargetLowering
217 int VarArgsFrameOffset
; // Frame offset to start of varargs area.
219 AMDILTargetLowering(TargetMachine
&TM
);
222 LowerOperation(SDValue Op
, SelectionDAG
&DAG
) const;
225 getVarArgsFrameOffset() const;
227 /// computeMaskedBitsForTargetNode - Determine which of
228 /// the bits specified
229 /// in Mask are known to be either zero or one and return them in
231 /// KnownZero/KnownOne bitsets.
233 computeMaskedBitsForTargetNode(
237 const SelectionDAG
&DAG
,
241 virtual MachineBasicBlock
*
242 EmitInstrWithCustomInserter(
244 MachineBasicBlock
*MBB
) const;
247 getTgtMemIntrinsic(IntrinsicInfo
&Info
,
248 const CallInst
&I
, unsigned Intrinsic
) const;
253 // We want to mark f32/f64 floating point values as
256 isFPImmLegal(const APFloat
&Imm
, EVT VT
) const;
257 // We don't want to shrink f64/f32 constants because
258 // they both take up the same amount of space and
259 // we don't want to use a f2d instruction.
260 bool ShouldShrinkFPConstant(EVT VT
) const;
262 /// getFunctionAlignment - Return the Log2 alignment of this
265 getFunctionAlignment(const Function
*F
) const;
269 CCAssignFnForNode(unsigned int CC
) const;
271 SDValue
LowerCallResult(SDValue Chain
,
273 CallingConv::ID CallConv
,
275 const SmallVectorImpl
<ISD::InputArg
> &Ins
,
278 SmallVectorImpl
<SDValue
> &InVals
) const;
280 SDValue
LowerMemArgument(SDValue Chain
,
281 CallingConv::ID CallConv
,
282 const SmallVectorImpl
<ISD::InputArg
> &ArgInfo
,
283 DebugLoc dl
, SelectionDAG
&DAG
,
284 const CCValAssign
&VA
, MachineFrameInfo
*MFI
,
287 SDValue
LowerMemOpCallTo(SDValue Chain
, SDValue StackPtr
,
289 DebugLoc dl
, SelectionDAG
&DAG
,
290 const CCValAssign
&VA
,
291 ISD::ArgFlagsTy Flags
) const;
294 LowerFormalArguments(SDValue Chain
,
295 CallingConv::ID CallConv
, bool isVarArg
,
296 const SmallVectorImpl
<ISD::InputArg
> &Ins
,
297 DebugLoc dl
, SelectionDAG
&DAG
,
298 SmallVectorImpl
<SDValue
> &InVals
) const;
301 LowerCall(SDValue Chain
, SDValue Callee
,
302 CallingConv::ID CallConv
, bool isVarArg
, bool doesNotRet
,
304 const SmallVectorImpl
<ISD::OutputArg
> &Outs
,
305 const SmallVectorImpl
<SDValue
> &OutVals
,
306 const SmallVectorImpl
<ISD::InputArg
> &Ins
,
307 DebugLoc dl
, SelectionDAG
&DAG
,
308 SmallVectorImpl
<SDValue
> &InVals
) const;
311 LowerReturn(SDValue Chain
,
312 CallingConv::ID CallConv
, bool isVarArg
,
313 const SmallVectorImpl
<ISD::OutputArg
> &Outs
,
314 const SmallVectorImpl
<SDValue
> &OutVals
,
315 DebugLoc dl
, SelectionDAG
&DAG
) const;
317 //+++--- Function dealing with conversions between floating point and
318 //integer types ---+++//
320 genCLZu64(SDValue Op
, SelectionDAG
&DAG
) const;
322 genCLZuN(SDValue Op
, SelectionDAG
&DAG
, uint32_t bits
) const;
324 genCLZu32(SDValue Op
, SelectionDAG
&DAG
) const;
326 genf64toi32(SDValue Op
, SelectionDAG
&DAG
,
327 bool includeSign
) const;
330 genf64toi64(SDValue Op
, SelectionDAG
&DAG
,
331 bool includeSign
) const;
334 genu32tof64(SDValue Op
, EVT dblvt
, SelectionDAG
&DAG
) const;
337 genu64tof64(SDValue Op
, EVT dblvt
, SelectionDAG
&DAG
) const;
340 LowerFP_TO_SINT(SDValue Op
, SelectionDAG
&DAG
) const;
343 LowerFP_TO_UINT(SDValue Op
, SelectionDAG
&DAG
) const;
346 LowerSINT_TO_FP(SDValue Op
, SelectionDAG
&DAG
) const;
349 LowerUINT_TO_FP(SDValue Op
, SelectionDAG
&DAG
) const;
352 LowerGlobalAddress(SDValue Op
, SelectionDAG
&DAG
) const;
355 LowerINTRINSIC_WO_CHAIN(SDValue Op
, SelectionDAG
& DAG
) const;
358 LowerINTRINSIC_W_CHAIN(SDValue Op
, SelectionDAG
& DAG
) const;
361 LowerINTRINSIC_VOID(SDValue Op
, SelectionDAG
& DAG
) const;
364 LowerJumpTable(SDValue Op
, SelectionDAG
&DAG
) const;
367 LowerConstantPool(SDValue Op
, SelectionDAG
&DAG
) const;
370 LowerExternalSymbol(SDValue Op
, SelectionDAG
&DAG
) const;
373 LowerADD(SDValue Op
, SelectionDAG
&DAG
) const;
376 LowerSUB(SDValue Op
, SelectionDAG
&DAG
) const;
379 LowerSREM(SDValue Op
, SelectionDAG
&DAG
) const;
381 LowerSREM8(SDValue Op
, SelectionDAG
&DAG
) const;
383 LowerSREM16(SDValue Op
, SelectionDAG
&DAG
) const;
385 LowerSREM32(SDValue Op
, SelectionDAG
&DAG
) const;
387 LowerSREM64(SDValue Op
, SelectionDAG
&DAG
) const;
390 LowerUREM(SDValue Op
, SelectionDAG
&DAG
) const;
392 LowerUREM8(SDValue Op
, SelectionDAG
&DAG
) const;
394 LowerUREM16(SDValue Op
, SelectionDAG
&DAG
) const;
396 LowerUREM32(SDValue Op
, SelectionDAG
&DAG
) const;
398 LowerUREM64(SDValue Op
, SelectionDAG
&DAG
) const;
401 LowerSDIV(SDValue Op
, SelectionDAG
&DAG
) const;
403 LowerSDIV24(SDValue Op
, SelectionDAG
&DAG
) const;
405 LowerSDIV32(SDValue Op
, SelectionDAG
&DAG
) const;
407 LowerSDIV64(SDValue Op
, SelectionDAG
&DAG
) const;
410 LowerUDIV(SDValue Op
, SelectionDAG
&DAG
) const;
412 LowerUDIV24(SDValue Op
, SelectionDAG
&DAG
) const;
414 LowerUDIV32(SDValue Op
, SelectionDAG
&DAG
) const;
416 LowerUDIV64(SDValue Op
, SelectionDAG
&DAG
) const;
419 LowerFDIV(SDValue Op
, SelectionDAG
&DAG
) const;
421 LowerFDIV32(SDValue Op
, SelectionDAG
&DAG
) const;
423 LowerFDIV64(SDValue Op
, SelectionDAG
&DAG
) const;
426 LowerMUL(SDValue Op
, SelectionDAG
&DAG
) const;
429 LowerBUILD_VECTOR(SDValue Op
, SelectionDAG
&DAG
) const;
432 LowerINSERT_VECTOR_ELT(SDValue Op
, SelectionDAG
&DAG
) const;
435 LowerEXTRACT_VECTOR_ELT(SDValue Op
, SelectionDAG
&DAG
) const;
438 LowerEXTRACT_SUBVECTOR(SDValue Op
, SelectionDAG
&DAG
) const;
441 LowerSCALAR_TO_VECTOR(SDValue Op
, SelectionDAG
&DAG
) const;
444 LowerCONCAT_VECTORS(SDValue Op
, SelectionDAG
&DAG
) const;
447 LowerAND(SDValue Op
, SelectionDAG
&DAG
) const;
450 LowerOR(SDValue Op
, SelectionDAG
&DAG
) const;
453 LowerSELECT(SDValue Op
, SelectionDAG
&DAG
) const;
456 LowerSELECT_CC(SDValue Op
, SelectionDAG
&DAG
) const;
459 LowerSETCC(SDValue Op
, SelectionDAG
&DAG
) const;
462 LowerSIGN_EXTEND_INREG(SDValue Op
, SelectionDAG
&DAG
) const;
465 genIntType(uint32_t size
= 32, uint32_t numEle
= 1) const;
468 LowerBITCAST(SDValue Op
, SelectionDAG
&DAG
) const;
471 LowerDYNAMIC_STACKALLOC(SDValue Op
, SelectionDAG
&DAG
) const;
474 LowerBRCOND(SDValue Op
, SelectionDAG
&DAG
) const;
477 LowerBR_CC(SDValue Op
, SelectionDAG
&DAG
) const;
479 LowerFP_ROUND(SDValue Op
, SelectionDAG
&DAG
) const;
481 generateCMPInstr(MachineInstr
*, MachineBasicBlock
*,
482 const TargetInstrInfo
&) const;
484 convertToReg(MachineOperand
) const;
486 // private members used by the set of instruction generation
487 // functions, these are marked mutable as they are cached so
488 // that they don't have to constantly be looked up when using the
489 // generateMachineInst/genVReg instructions. This is to simplify
491 // and to make it cleaner. The object itself doesn't change as
492 // only these functions use these three data types.
493 mutable MachineBasicBlock
*mBB
;
494 mutable DebugLoc
*mDL
;
495 mutable const TargetInstrInfo
*mTII
;
496 mutable MachineBasicBlock::iterator mBBI
;
498 setPrivateData(MachineBasicBlock
*BB
,
499 MachineBasicBlock::iterator
&BBI
,
501 const TargetInstrInfo
*TII
) const;
502 uint32_t genVReg(uint32_t regType
) const;
504 generateMachineInst(uint32_t opcode
,
507 generateMachineInst(uint32_t opcode
,
508 uint32_t dst
, uint32_t src1
) const;
510 generateMachineInst(uint32_t opcode
,
511 uint32_t dst
, uint32_t src1
, uint32_t src2
) const;
513 generateMachineInst(uint32_t opcode
,
514 uint32_t dst
, uint32_t src1
, uint32_t src2
,
515 uint32_t src3
) const;
517 addExtensionInstructions(
518 uint32_t reg
, bool signedShift
,
519 unsigned int simpleVT
) const;
521 generateLongRelational(MachineInstr
*MI
,
522 unsigned int opCode
) const;
524 }; // AMDILTargetLowering
525 } // end namespace llvm
527 #endif // AMDIL_ISELLOWERING_H_