X86ISelLowering.h revision 64b7bf71e84094193b40ab81aa7dacad921ecbea
11c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner//===-- X86ISelLowering.h - X86 DAG Lowering Interface ----------*- C++ -*-===//
2edf128a7fa90f2b0b7ee24741a04a7ae1ecd6f7eMisha Brukman//
31c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner//                     The LLVM Compiler Infrastructure
41c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner//
54ee451de366474b9c228b4e5fa573795a715216dChris Lattner// This file is distributed under the University of Illinois Open Source
64ee451de366474b9c228b4e5fa573795a715216dChris Lattner// License. See LICENSE.TXT for details.
7edf128a7fa90f2b0b7ee24741a04a7ae1ecd6f7eMisha Brukman//
81c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner//===----------------------------------------------------------------------===//
91c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner//
101c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner// This file defines the interfaces that X86 uses to lower LLVM code into a
111c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner// selection DAG.
121c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner//
131c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner//===----------------------------------------------------------------------===//
141c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
155502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov#ifndef X86ISELLOWERING_H
16c7c3f110eda0ff8040e4bd99e38d3112b910810fJim Laskey#define X86ISELLOWERING_H
171c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
18a9c2091cd38e401c846391c9951ff416e709b65eEvan Cheng#include "X86Subtarget.h"
195502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov#include "X86RegisterInfo.h"
20adf6a965a321372c640845407195594835921eb4Chris Lattner#include "X86MachineFunctionInfo.h"
211c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner#include "llvm/Target/TargetLowering.h"
221c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner#include "llvm/Target/TargetOptions.h"
2336ce69195ed488034d0bb11180cc2ebd923679c8Chris Lattner#include "llvm/CodeGen/FastISel.h"
24ce7518ce92f45568dc7d4cbb863284afb962fec5Chris Lattner#include "llvm/CodeGen/SelectionDAG.h"
251c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner#include "llvm/CodeGen/CallingConvLower.h"
261c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
2743970fec322d9e0153ca513de41d80af1c79bddeJim Laskeynamespace llvm {
285694b6e90eaf94fa7a21f101a8e4424d813a85ceReid Spencer  namespace X86ISD {
29ce2247755e56f99a2377b64a1a9d393726582b85Gordon Henriksen    // X86 Specific DAG Nodes
301c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    enum NodeType {
311c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      // Start the numbering where the builtin ops leave off.
321c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      FIRST_NUMBER = ISD::BUILTIN_OP_END,
3384bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner
3484bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner      /// BSF - Bit scan forward.
3584bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner      /// BSR - Bit scan reverse.
36eb577ba3b815a1fa4627b060dd2345d17abf672dJim Laskey      BSF,
371c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      BSR,
38fa57702388f139e964befecb4b98c7dfe836945fChris Lattner
391c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      /// SHLD, SHRD - Double shift instructions. These correspond to
401c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      /// X86::SHLDxx and X86::SHRDxx instructions.
411c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      SHLD,
421c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      SHRD,
431c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
44124729155d860a0850eb4ef2a7cea4145e13a057Vladimir Prus      /// FAND - Bitwise logical AND of floating point values. This corresponds
457c0104b525a4ba8b5268ee5455f92b011f7cc263Chris Lattner      /// to X86::ANDPS or X86::ANDPD.
461c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      FAND,
47a4f0b3a084d120cfc5b5bb06f64b222f5cb72740Chris Lattner
487e88103cdea8c36b2229dae8c60def14e3816512Jeff Cohen      /// FOR - Bitwise logical OR of floating point values. This corresponds
491c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      /// to X86::ORPS or X86::ORPD.
501c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      FOR,
51da8abb02397d7cd62a1e16e7c534edd7096ac873Chris Lattner
527944d9d9957db1efe085d9df3ea89826f50029b7Chris Lattner      /// FXOR - Bitwise logical XOR of floating point values. This corresponds
53a9c2091cd38e401c846391c9951ff416e709b65eEvan Cheng      /// to X86::XORPS or X86::XORPD.
54a9c2091cd38e401c846391c9951ff416e709b65eEvan Cheng      FXOR,
55a9c2091cd38e401c846391c9951ff416e709b65eEvan Cheng
56a9c2091cd38e401c846391c9951ff416e709b65eEvan Cheng      /// FSRL - Bitwise logical right shift of floating point values. These
57a9c2091cd38e401c846391c9951ff416e709b65eEvan Cheng      /// corresponds to X86::PSRLDQ.
583e1a7aef17575d9c7058a035449d57e3c7295ed0Dan Gohman      FSRL,
593e1a7aef17575d9c7058a035449d57e3c7295ed0Dan Gohman
605bab78527a946632cd9614daa0b9a82ee7b5e1ccChris Lattner      /// FILD, FILD_FLAG - This instruction implements SINT_TO_FP with the
617944d9d9957db1efe085d9df3ea89826f50029b7Chris Lattner      /// integer source in memory and FP reg result.  This corresponds to the
623e1a7aef17575d9c7058a035449d57e3c7295ed0Dan Gohman      /// X86::FILD*m instructions. It has three inputs (token chain, address,
637944d9d9957db1efe085d9df3ea89826f50029b7Chris Lattner      /// and source type) and two outputs (FP value and token chain). FILD_FLAG
647944d9d9957db1efe085d9df3ea89826f50029b7Chris Lattner      /// also produces a flag).
65eb577ba3b815a1fa4627b060dd2345d17abf672dJim Laskey      FILD,
66eb577ba3b815a1fa4627b060dd2345d17abf672dJim Laskey      FILD_FLAG,
67eb577ba3b815a1fa4627b060dd2345d17abf672dJim Laskey
68eb577ba3b815a1fa4627b060dd2345d17abf672dJim Laskey      /// FP_TO_INT*_IN_MEM - This instruction implements FP_TO_SINT with the
69eb577ba3b815a1fa4627b060dd2345d17abf672dJim Laskey      /// integer destination in memory and a FP reg source.  This corresponds
70eb577ba3b815a1fa4627b060dd2345d17abf672dJim Laskey      /// to the X86::FIST*m instructions and the rounding mode change stuff. It
71eb577ba3b815a1fa4627b060dd2345d17abf672dJim Laskey      /// has two inputs (token chain and address) and two outputs (int value
72eb577ba3b815a1fa4627b060dd2345d17abf672dJim Laskey      /// and token chain).
73eb577ba3b815a1fa4627b060dd2345d17abf672dJim Laskey      FP_TO_INT16_IN_MEM,
74eb577ba3b815a1fa4627b060dd2345d17abf672dJim Laskey      FP_TO_INT32_IN_MEM,
75eb577ba3b815a1fa4627b060dd2345d17abf672dJim Laskey      FP_TO_INT64_IN_MEM,
76eb577ba3b815a1fa4627b060dd2345d17abf672dJim Laskey
774ef10867499aa146cd819c78d8d37a8353d4f0ffEvan Cheng      /// FLD - This instruction implements an extending load to FP stack slots.
78eb577ba3b815a1fa4627b060dd2345d17abf672dJim Laskey      /// This corresponds to the X86::FLD32m / X86::FLD64m. It takes a chain
79eb577ba3b815a1fa4627b060dd2345d17abf672dJim Laskey      /// operand, ptr to load from, and a ValueType node indicating the type
80e7e7d0d7e39d0c7c659d26b97e8081fce0fcd749Dale Johannesen      /// to load to.
813700f90c19f51deae00f85b80d31e1f7fbda1f99Chris Lattner      FLD,
825bab78527a946632cd9614daa0b9a82ee7b5e1ccChris Lattner
835bab78527a946632cd9614daa0b9a82ee7b5e1ccChris Lattner      /// FST - This instruction implements a truncating store to FP stack
8413ec702c430b91ee49b9e6d9581cd95412f216c8Jim Laskey      /// slots. This corresponds to the X86::FST32m / X86::FST64m. It takes a
859ff542f2cce5bf7bf3cf9f692cf3ec0690ad2b3bJim Laskey      /// chain operand, value to store, address, and a ValueType to store it
869373beba6010dd34316a801c3a9b37ab9e048031Jim Laskey      /// as.
879373beba6010dd34316a801c3a9b37ab9e048031Jim Laskey      FST,
884ef10867499aa146cd819c78d8d37a8353d4f0ffEvan Cheng
894ef10867499aa146cd819c78d8d37a8353d4f0ffEvan Cheng      /// CALL - These operations represent an abstract X86 call
90bf996f1d5e441c7504ff155d818190f593d54672Chris Lattner      /// instruction, which includes a bunch of information.  In particular the
91bf996f1d5e441c7504ff155d818190f593d54672Chris Lattner      /// operands of these node are:
92864635ad7b3046d3042311423071152c613961deChris Lattner      ///
93864635ad7b3046d3042311423071152c613961deChris Lattner      ///     #0 - The incoming token chain
94864635ad7b3046d3042311423071152c613961deChris Lattner      ///     #1 - The callee
95864635ad7b3046d3042311423071152c613961deChris Lattner      ///     #2 - The number of arg bytes the caller pushes on the stack.
96864635ad7b3046d3042311423071152c613961deChris Lattner      ///     #3 - The number of arg bytes the callee pops off the stack.
979525528a7dc5462b6374d38c81ba5c07b11741feChris Lattner      ///     #4 - The value to pass in AL/AX/EAX (optional)
98b6f5b00c3bad3415d3f2ee1a6d5ee5a6f66a4540Dan Gohman      ///     #5 - The value to pass in DL/DX/EDX (optional)
99864635ad7b3046d3042311423071152c613961deChris Lattner      ///
100864635ad7b3046d3042311423071152c613961deChris Lattner      /// The result values of these nodes are:
101864635ad7b3046d3042311423071152c613961deChris Lattner      ///
102864635ad7b3046d3042311423071152c613961deChris Lattner      ///     #0 - The outgoing token chain
103864635ad7b3046d3042311423071152c613961deChris Lattner      ///     #1 - The first register result value (optional)
104864635ad7b3046d3042311423071152c613961deChris Lattner      ///     #2 - The second register result value (optional)
105864635ad7b3046d3042311423071152c613961deChris Lattner      ///
106864635ad7b3046d3042311423071152c613961deChris Lattner      CALL,
107864635ad7b3046d3042311423071152c613961deChris Lattner
108864635ad7b3046d3042311423071152c613961deChris Lattner      /// RDTSC_DAG - This operation implements the lowering for
109864635ad7b3046d3042311423071152c613961deChris Lattner      /// readcyclecounter
110864635ad7b3046d3042311423071152c613961deChris Lattner      RDTSC_DAG,
111864635ad7b3046d3042311423071152c613961deChris Lattner
112864635ad7b3046d3042311423071152c613961deChris Lattner      /// X86 compare and logical compare instructions.
113864635ad7b3046d3042311423071152c613961deChris Lattner      CMP, COMI, UCOMI,
114864635ad7b3046d3042311423071152c613961deChris Lattner
115864635ad7b3046d3042311423071152c613961deChris Lattner      /// X86 bit-test instructions.
116864635ad7b3046d3042311423071152c613961deChris Lattner      BT,
117864635ad7b3046d3042311423071152c613961deChris Lattner
118864635ad7b3046d3042311423071152c613961deChris Lattner      /// X86 SetCC. Operand 0 is condition code, and operand 1 is the flag
119864635ad7b3046d3042311423071152c613961deChris Lattner      /// operand produced by a CMP instruction.
120864635ad7b3046d3042311423071152c613961deChris Lattner      SETCC,
121864635ad7b3046d3042311423071152c613961deChris Lattner
122864635ad7b3046d3042311423071152c613961deChris Lattner      // Same as SETCC except it's materialized with a sbb and the value is all
123864635ad7b3046d3042311423071152c613961deChris Lattner      // one's or all zero's.
124864635ad7b3046d3042311423071152c613961deChris Lattner      SETCC_CARRY,
125b6f5b00c3bad3415d3f2ee1a6d5ee5a6f66a4540Dan Gohman
126864635ad7b3046d3042311423071152c613961deChris Lattner      /// X86 conditional moves. Operand 0 and operand 1 are the two values
127b6f5b00c3bad3415d3f2ee1a6d5ee5a6f66a4540Dan Gohman      /// to select from. Operand 2 is the condition code, and operand 3 is the
128c3a9f8d31ce93ba384bd2bbdd55c757b06600a15Chris Lattner      /// flag operand produced by a CMP or TEST instruction. It also writes a
129c3a9f8d31ce93ba384bd2bbdd55c757b06600a15Chris Lattner      /// flag result.
130c3a9f8d31ce93ba384bd2bbdd55c757b06600a15Chris Lattner      CMOV,
131c3a9f8d31ce93ba384bd2bbdd55c757b06600a15Chris Lattner
132b6f5b00c3bad3415d3f2ee1a6d5ee5a6f66a4540Dan Gohman      /// X86 conditional branches. Operand 0 is the chain operand, operand 1
133c3a9f8d31ce93ba384bd2bbdd55c757b06600a15Chris Lattner      /// is the block to branch if condition is true, operand 2 is the
134b6f5b00c3bad3415d3f2ee1a6d5ee5a6f66a4540Dan Gohman      /// condition code, and operand 3 is the flag operand produced by a CMP
135c3a9f8d31ce93ba384bd2bbdd55c757b06600a15Chris Lattner      /// or TEST instruction.
136c3a9f8d31ce93ba384bd2bbdd55c757b06600a15Chris Lattner      BRCOND,
137c3a9f8d31ce93ba384bd2bbdd55c757b06600a15Chris Lattner
138c3a9f8d31ce93ba384bd2bbdd55c757b06600a15Chris Lattner      /// Return with a flag operand. Operand 0 is the chain operand, operand
139c3a9f8d31ce93ba384bd2bbdd55c757b06600a15Chris Lattner      /// 1 is the number of bytes of stack to pop.
1409f6637db10642fae51fa3628b7833c6999f7fdb3Chris Lattner      RET_FLAG,
141864635ad7b3046d3042311423071152c613961deChris Lattner
142864635ad7b3046d3042311423071152c613961deChris Lattner      /// REP_STOS - Repeat fill, corresponds to X86::REP_STOSx.
1434ef10867499aa146cd819c78d8d37a8353d4f0ffEvan Cheng      REP_STOS,
1441c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
1451c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      /// REP_MOVS - Repeat move, corresponds to X86::REP_MOVSx.
1469373beba6010dd34316a801c3a9b37ab9e048031Jim Laskey      REP_MOVS,
1479373beba6010dd34316a801c3a9b37ab9e048031Jim Laskey
1489373beba6010dd34316a801c3a9b37ab9e048031Jim Laskey      /// GlobalBaseReg - On Darwin, this node represents the result of the popl
1499373beba6010dd34316a801c3a9b37ab9e048031Jim Laskey      /// at function entry, used for PIC code.
1509373beba6010dd34316a801c3a9b37ab9e048031Jim Laskey      GlobalBaseReg,
1519373beba6010dd34316a801c3a9b37ab9e048031Jim Laskey
1529373beba6010dd34316a801c3a9b37ab9e048031Jim Laskey      /// Wrapper - A wrapper node for TargetConstantPool,
1539373beba6010dd34316a801c3a9b37ab9e048031Jim Laskey      /// TargetExternalSymbol, and TargetGlobalAddress.
1549373beba6010dd34316a801c3a9b37ab9e048031Jim Laskey      Wrapper,
1559373beba6010dd34316a801c3a9b37ab9e048031Jim Laskey
1569373beba6010dd34316a801c3a9b37ab9e048031Jim Laskey      /// WrapperRIP - Special wrapper used under X86-64 PIC mode for RIP
1579373beba6010dd34316a801c3a9b37ab9e048031Jim Laskey      /// relative displacements.
1589373beba6010dd34316a801c3a9b37ab9e048031Jim Laskey      WrapperRIP,
1599373beba6010dd34316a801c3a9b37ab9e048031Jim Laskey
1609373beba6010dd34316a801c3a9b37ab9e048031Jim Laskey      /// MOVQ2DQ - Copies a 64-bit value from a vector to another vector.
1619373beba6010dd34316a801c3a9b37ab9e048031Jim Laskey      /// Can be used to move a vector value from a MMX register to a XMM
1629373beba6010dd34316a801c3a9b37ab9e048031Jim Laskey      /// register.
1639373beba6010dd34316a801c3a9b37ab9e048031Jim Laskey      MOVQ2DQ,
1641c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
1651c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      /// PEXTRB - Extract an 8-bit value from a vector and zero extend it to
166f26bc8ef4827cf0023a7052b62b920b41813d473Chris Lattner      /// i32, corresponds to X86::PEXTRB.
167f26bc8ef4827cf0023a7052b62b920b41813d473Chris Lattner      PEXTRB,
1681c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
1691c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      /// PEXTRW - Extract a 16-bit value from a vector and zero extend it to
1701c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      /// i32, corresponds to X86::PEXTRW.
17184bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner      PEXTRW,
1721c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
1731c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      /// INSERTPS - Insert any element of a 4 x float vector into any element
1741c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      /// of a destination 4 x floatvector.
1751c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      INSERTPS,
1761c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
1771c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      /// PINSRB - Insert the lower 8-bits of a 32-bit value to a vector,
1781c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      /// corresponds to X86::PINSRB.
1791c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      PINSRB,
1801c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
1819f24ad79ce32200b06499ef638b502fc1c36ed04Chris Lattner      /// PINSRW - Insert the lower 16-bits of a 32-bit value to a vector,
1821c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      /// corresponds to X86::PINSRW.
1831c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      PINSRW, MMX_PINSRW,
1841c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
1851c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      /// PSHUFB - Shuffle 16 8-bit values within a vector.
1861c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      PSHUFB,
1871c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
188f40708223e409a152834b1553c6883ff2035b957Duncan Sands      /// FMAX, FMIN - Floating point max and min.
189f40708223e409a152834b1553c6883ff2035b957Duncan Sands      ///
190f40708223e409a152834b1553c6883ff2035b957Duncan Sands      FMAX, FMIN,
191f40708223e409a152834b1553c6883ff2035b957Duncan Sands
192f40708223e409a152834b1553c6883ff2035b957Duncan Sands      /// FRSQRT, FRCP - Floating point reciprocal-sqrt and reciprocal
1931c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      /// approximation.  Note that these typically require refinement
19484bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner      /// in order to obtain suitable precision.
1951c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      FRSQRT, FRCP,
196571e434a34e26f295f13db2dd07551de7e25f8a9Chris Lattner
197571e434a34e26f295f13db2dd07551de7e25f8a9Chris Lattner      // TLSADDR - Thread Local Storage.
198571e434a34e26f295f13db2dd07551de7e25f8a9Chris Lattner      TLSADDR,
199571e434a34e26f295f13db2dd07551de7e25f8a9Chris Lattner
200571e434a34e26f295f13db2dd07551de7e25f8a9Chris Lattner      // SegmentBaseAddress - The address segment:0
201571e434a34e26f295f13db2dd07551de7e25f8a9Chris Lattner      SegmentBaseAddress,
202edf128a7fa90f2b0b7ee24741a04a7ae1ecd6f7eMisha Brukman
2033c38449be6371d53a58d0df80ecf3772a2f9a79fChris Lattner      // EH_RETURN - Exception Handling helpers.
2043c38449be6371d53a58d0df80ecf3772a2f9a79fChris Lattner      EH_RETURN,
2051c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
2061c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      /// TC_RETURN - Tail call return.
2071c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      ///   operand #0 chain
2081c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      ///   operand #1 callee (register or absolute)
2091c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      ///   operand #2 stack adjustment
2101c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      ///   operand #3 optional in flag
2111c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      TC_RETURN,
2121c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
213cf26d7ccac1ad052b750edec36b13bc9ea8f70d7Duncan Sands      // LCMPXCHG_DAG, LCMPXCHG8_DAG - Compare and swap.
214cf26d7ccac1ad052b750edec36b13bc9ea8f70d7Duncan Sands      LCMPXCHG_DAG,
215cf26d7ccac1ad052b750edec36b13bc9ea8f70d7Duncan Sands      LCMPXCHG8_DAG,
216f40708223e409a152834b1553c6883ff2035b957Duncan Sands
2178806c7b1f5317a9679a5779ffc08c552f2091bceAnton Korobeynikov      // FNSTCW16m - Store FP control world into i16 memory.
2188806c7b1f5317a9679a5779ffc08c552f2091bceAnton Korobeynikov      FNSTCW16m,
219f40708223e409a152834b1553c6883ff2035b957Duncan Sands
220f40708223e409a152834b1553c6883ff2035b957Duncan Sands      // VZEXT_MOVL - Vector move low and zero extend.
221f40708223e409a152834b1553c6883ff2035b957Duncan Sands      VZEXT_MOVL,
2221c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
223f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman      // VZEXT_LOAD - Load, scalar_to_vector, and zero extend.
224f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman      VZEXT_LOAD,
2251c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
2261c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      // VSHL, VSRL - Vector logical left / right shift.
2271c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      VSHL, VSRL,
2281c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
229f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman      // CMPPD, CMPPS - Vector double/float comparison.
230571e434a34e26f295f13db2dd07551de7e25f8a9Chris Lattner      // CMPPD, CMPPS - Vector double/float comparison.
231f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman      CMPPD, CMPPS,
2321c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
2331c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      // PCMP* - Vector integer comparisons.
2341c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      PCMPEQB, PCMPEQW, PCMPEQD, PCMPEQQ,
2351c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      PCMPGTB, PCMPGTW, PCMPGTD, PCMPGTQ,
236bf209489ad3f7a38ce6b2159b22d8727500e60c2Chris Lattner
237f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman      // ADD, SUB, SMUL, UMUL, etc. - Arithmetic operations with FLAGS results.
238f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman      ADD, SUB, SMUL, UMUL,
239bf209489ad3f7a38ce6b2159b22d8727500e60c2Chris Lattner      INC, DEC, OR, XOR, AND,
240bf209489ad3f7a38ce6b2159b22d8727500e60c2Chris Lattner
241bf209489ad3f7a38ce6b2159b22d8727500e60c2Chris Lattner      // MUL_IMM - X86 specific multiply by immediate.
242f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman      MUL_IMM,
243bf209489ad3f7a38ce6b2159b22d8727500e60c2Chris Lattner
244bf209489ad3f7a38ce6b2159b22d8727500e60c2Chris Lattner      // PTEST - Vector bitwise comparisons
245bf209489ad3f7a38ce6b2159b22d8727500e60c2Chris Lattner      PTEST,
246bf209489ad3f7a38ce6b2159b22d8727500e60c2Chris Lattner
2471c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      // VASTART_SAVE_XMM_REGS - Save xmm argument registers to the stack,
248edf128a7fa90f2b0b7ee24741a04a7ae1ecd6f7eMisha Brukman      // according to %al. An operator is needed so that this can be expanded
24984bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner      // with control flow.
2501c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      VASTART_SAVE_XMM_REGS,
251bf209489ad3f7a38ce6b2159b22d8727500e60c2Chris Lattner
252bf209489ad3f7a38ce6b2159b22d8727500e60c2Chris Lattner      // MINGW_ALLOCA - MingW's __alloca call to do stack probing.
25316ce0df92717cd1474029d87efe596d000dc2caaChris Lattner      MINGW_ALLOCA,
25416ce0df92717cd1474029d87efe596d000dc2caaChris Lattner
255bf209489ad3f7a38ce6b2159b22d8727500e60c2Chris Lattner      // ATOMADD64_DAG, ATOMSUB64_DAG, ATOMOR64_DAG, ATOMAND64_DAG,
256bf209489ad3f7a38ce6b2159b22d8727500e60c2Chris Lattner      // ATOMXOR64_DAG, ATOMNAND64_DAG, ATOMSWAP64_DAG -
2571c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      // Atomic 64-bit binary operations.
258bf209489ad3f7a38ce6b2159b22d8727500e60c2Chris Lattner      ATOMADD64_DAG = ISD::FIRST_TARGET_MEMORY_OPCODE,
259bf209489ad3f7a38ce6b2159b22d8727500e60c2Chris Lattner      ATOMSUB64_DAG,
260bf209489ad3f7a38ce6b2159b22d8727500e60c2Chris Lattner      ATOMOR64_DAG,
2612aeaf4e839438d51766996006fc22310d05ab2a7Jeff Cohen      ATOMXOR64_DAG,
2621c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      ATOMAND64_DAG,
2631c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      ATOMNAND64_DAG,
264b83eb6447ba155342598f0fabe1f08f5baa9164aReid Spencer      ATOMSWAP64_DAG
2651c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
266514ab348fddcdffa8367685dc608b2f8d5de986dDuncan Sands      // WARNING: Do not add anything in the end unless you want the node to
267ae232e7a1055033436370c0b3aecf054fa44d5e7Nate Begeman      // have memop! In fact, starting from ATOMADD64_DAG all opcodes will be
268d2b7cec527a0efa552628378ebca7a8ca63bb45dChris Lattner      // thought as target memory ops!
269ae232e7a1055033436370c0b3aecf054fa44d5e7Nate Begeman    };
270a8217e3000b5b01c4a95316aef078a9d02a9a119Chris Lattner  }
271b83eb6447ba155342598f0fabe1f08f5baa9164aReid Spencer
272d222f6ab67472fa2b2e211172a11b43905aa9445Chris Lattner  /// Define some predicates that are used for node matching.
2731c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner  namespace X86 {
2746266c18ea12b42bd9b262a1f4f8c3d7a85130118Chris Lattner    /// isPSHUFDMask - Return true if the specified VECTOR_SHUFFLE operand
2751c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// specifies a shuffle of elements that is suitable for input to PSHUFD.
2761c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    bool isPSHUFDMask(ShuffleVectorSDNode *N);
2772aeaf4e839438d51766996006fc22310d05ab2a7Jeff Cohen
2782aeaf4e839438d51766996006fc22310d05ab2a7Jeff Cohen    /// isPSHUFHWMask - Return true if the specified VECTOR_SHUFFLE operand
2791c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// specifies a shuffle of elements that is suitable for input to PSHUFD.
2801c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    bool isPSHUFHWMask(ShuffleVectorSDNode *N);
2811c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
2821c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// isPSHUFLWMask - Return true if the specified VECTOR_SHUFFLE operand
2831c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// specifies a shuffle of elements that is suitable for input to PSHUFD.
2841c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    bool isPSHUFLWMask(ShuffleVectorSDNode *N);
2851c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
2861c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// isSHUFPMask - Return true if the specified VECTOR_SHUFFLE operand
2872aeaf4e839438d51766996006fc22310d05ab2a7Jeff Cohen    /// specifies a shuffle of elements that is suitable for input to SHUFP*.
2881c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    bool isSHUFPMask(ShuffleVectorSDNode *N);
2891c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
2901c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// isMOVHLPSMask - Return true if the specified VECTOR_SHUFFLE operand
2911c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// specifies a shuffle of elements that is suitable for input to MOVHLPS.
2921c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    bool isMOVHLPSMask(ShuffleVectorSDNode *N);
2931c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
2941c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// isMOVHLPS_v_undef_Mask - Special case of isMOVHLPSMask for canonical form
2958c494ab759266322aa05d5e99af9c05eb0d44576Chris Lattner    /// of vector_shuffle v, v, <2, 3, 2, 3>, i.e. vector_shuffle v, undef,
2968c494ab759266322aa05d5e99af9c05eb0d44576Chris Lattner    /// <2, 3, 2, 3>
2978c494ab759266322aa05d5e99af9c05eb0d44576Chris Lattner    bool isMOVHLPS_v_undef_Mask(ShuffleVectorSDNode *N);
2988c494ab759266322aa05d5e99af9c05eb0d44576Chris Lattner
2997f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// isMOVLPMask - Return true if the specified VECTOR_SHUFFLE operand
3008c494ab759266322aa05d5e99af9c05eb0d44576Chris Lattner    /// specifies a shuffle of elements that is suitable for MOVLP{S|D}.
3018c494ab759266322aa05d5e99af9c05eb0d44576Chris Lattner    bool isMOVLPMask(ShuffleVectorSDNode *N);
302c0f64ffab93d11fb27a3b8a0707b77400918a20eEvan Cheng
303b9f10196961ebe5b5573a5705048a5a8a6b56bb3Dan Gohman    /// isMOVHPMask - Return true if the specified VECTOR_SHUFFLE operand
304c0f64ffab93d11fb27a3b8a0707b77400918a20eEvan Cheng    /// specifies a shuffle of elements that is suitable for MOVHP{S|D}.
3058c494ab759266322aa05d5e99af9c05eb0d44576Chris Lattner    /// as well as MOVLHPS.
3061c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    bool isMOVLHPSMask(ShuffleVectorSDNode *N);
3071c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
3081c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// isUNPCKLMask - Return true if the specified VECTOR_SHUFFLE operand
3093c38449be6371d53a58d0df80ecf3772a2f9a79fChris Lattner    /// specifies a shuffle of elements that is suitable for input to UNPCKL.
3103c38449be6371d53a58d0df80ecf3772a2f9a79fChris Lattner    bool isUNPCKLMask(ShuffleVectorSDNode *N, bool V2IsSplat = false);
3113c38449be6371d53a58d0df80ecf3772a2f9a79fChris Lattner
3123c38449be6371d53a58d0df80ecf3772a2f9a79fChris Lattner    /// isUNPCKHMask - Return true if the specified VECTOR_SHUFFLE operand
3133c38449be6371d53a58d0df80ecf3772a2f9a79fChris Lattner    /// specifies a shuffle of elements that is suitable for input to UNPCKH.
3143c38449be6371d53a58d0df80ecf3772a2f9a79fChris Lattner    bool isUNPCKHMask(ShuffleVectorSDNode *N, bool V2IsSplat = false);
315b6f5b00c3bad3415d3f2ee1a6d5ee5a6f66a4540Dan Gohman
316b6f5b00c3bad3415d3f2ee1a6d5ee5a6f66a4540Dan Gohman    /// isUNPCKL_v_undef_Mask - Special case of isUNPCKLMask for canonical form
31795b39550344bad0d15d1ffa7afc300eb1533ed19Bill Wendling    /// of vector_shuffle v, v, <0, 4, 1, 5>, i.e. vector_shuffle v, undef,
3188c8c5fcbd757b5c44fa7ad9af038a2f2d950b624Dan Gohman    /// <0, 0, 1, 1>
3198c8c5fcbd757b5c44fa7ad9af038a2f2d950b624Dan Gohman    bool isUNPCKL_v_undef_Mask(ShuffleVectorSDNode *N);
3208c8c5fcbd757b5c44fa7ad9af038a2f2d950b624Dan Gohman
3218c8c5fcbd757b5c44fa7ad9af038a2f2d950b624Dan Gohman    /// isUNPCKH_v_undef_Mask - Special case of isUNPCKHMask for canonical form
3223c38449be6371d53a58d0df80ecf3772a2f9a79fChris Lattner    /// of vector_shuffle v, v, <2, 6, 3, 7>, i.e. vector_shuffle v, undef,
3233c38449be6371d53a58d0df80ecf3772a2f9a79fChris Lattner    /// <2, 2, 3, 3>
3241c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    bool isUNPCKH_v_undef_Mask(ShuffleVectorSDNode *N);
3251c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
3261c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// isMOVLMask - Return true if the specified VECTOR_SHUFFLE operand
3271c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// specifies a shuffle of elements that is suitable for input to MOVSS,
3281c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// MOVSD, and MOVD, i.e. setting the lowest element.
3291c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    bool isMOVLMask(ShuffleVectorSDNode *N);
3301c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
3311c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// isMOVSHDUPMask - Return true if the specified VECTOR_SHUFFLE operand
3321c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// specifies a shuffle of elements that is suitable for input to MOVSHDUP.
3331c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    bool isMOVSHDUPMask(ShuffleVectorSDNode *N);
3340da331fe0bff24e6c90c706ef8f1f1c3a8d90c2aChris Lattner
3351c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// isMOVSLDUPMask - Return true if the specified VECTOR_SHUFFLE operand
336d3948116b81b11e82246c11389a9b4ce7e619fbbChris Lattner    /// specifies a shuffle of elements that is suitable for input to MOVSLDUP.
337d3948116b81b11e82246c11389a9b4ce7e619fbbChris Lattner    bool isMOVSLDUPMask(ShuffleVectorSDNode *N);
338d3948116b81b11e82246c11389a9b4ce7e619fbbChris Lattner
339d3948116b81b11e82246c11389a9b4ce7e619fbbChris Lattner    /// isMOVDDUPMask - Return true if the specified VECTOR_SHUFFLE operand
340d3948116b81b11e82246c11389a9b4ce7e619fbbChris Lattner    /// specifies a shuffle of elements that is suitable for input to MOVDDUP.
341d3948116b81b11e82246c11389a9b4ce7e619fbbChris Lattner    bool isMOVDDUPMask(ShuffleVectorSDNode *N);
3425502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov
3435502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov    /// isPALIGNRMask - Return true if the specified VECTOR_SHUFFLE operand
3445502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov    /// specifies a shuffle of elements that is suitable for input to PALIGNR.
3455502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov    bool isPALIGNRMask(ShuffleVectorSDNode *N);
3465502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov
3475502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov    /// getShuffleSHUFImmediate - Return the appropriate immediate to shuffle
3485502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov    /// the specified isShuffleMask VECTOR_SHUFFLE mask with PSHUF* and SHUFP*
3495502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov    /// instructions.
3505502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov    unsigned getShuffleSHUFImmediate(SDNode *N);
3515502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov
3525502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov    /// getShufflePSHUFHWImmediate - Return the appropriate immediate to shuffle
3535502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov    /// the specified VECTOR_SHUFFLE mask with PSHUFHW instruction.
3545502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov    unsigned getShufflePSHUFHWImmediate(SDNode *N);
3555502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov
3565502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov    /// getShufflePSHUFLWImmediate - Return the appropriate immediate to shuffle
3575502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov    /// the specified VECTOR_SHUFFLE mask with PSHUFLW instruction.
3585502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov    unsigned getShufflePSHUFLWImmediate(SDNode *N);
3594198c58c716cbe4516ac3a1a407a3cd52548bc3bAnton Korobeynikov
3604198c58c716cbe4516ac3a1a407a3cd52548bc3bAnton Korobeynikov    /// getShufflePALIGNRImmediate - Return the appropriate immediate to shuffle
3614198c58c716cbe4516ac3a1a407a3cd52548bc3bAnton Korobeynikov    /// the specified VECTOR_SHUFFLE mask with the PALIGNR instruction.
3624198c58c716cbe4516ac3a1a407a3cd52548bc3bAnton Korobeynikov    unsigned getShufflePALIGNRImmediate(SDNode *N);
3634198c58c716cbe4516ac3a1a407a3cd52548bc3bAnton Korobeynikov
3644198c58c716cbe4516ac3a1a407a3cd52548bc3bAnton Korobeynikov    /// isZeroNode - Returns true if Elt is a constant zero or a floating point
3654198c58c716cbe4516ac3a1a407a3cd52548bc3bAnton Korobeynikov    /// constant +0.0.
3664198c58c716cbe4516ac3a1a407a3cd52548bc3bAnton Korobeynikov    bool isZeroNode(SDValue Elt);
3674198c58c716cbe4516ac3a1a407a3cd52548bc3bAnton Korobeynikov
3685502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov    /// isOffsetSuitableForCodeModel - Returns true of the given offset can be
3694198c58c716cbe4516ac3a1a407a3cd52548bc3bAnton Korobeynikov    /// fit into displacement field of the instruction.
3705502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov    bool isOffsetSuitableForCodeModel(int64_t Offset, CodeModel::Model M,
3715502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov                                      bool hasSymbolicDisplacement = true);
372f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman  }
373f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman
374f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman  //===--------------------------------------------------------------------===//
375f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman  //  X86TargetLowering - X86 Implementation of the TargetLowering interface
376f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman  class X86TargetLowering : public TargetLowering {
377f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman    int VarArgsFrameIndex;            // FrameIndex for start of varargs area.
378f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman    int RegSaveFrameIndex;            // X86-64 vararg func register save area.
379f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman    unsigned VarArgsGPOffset;         // X86-64 vararg func int reg offset.
380f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman    unsigned VarArgsFPOffset;         // X86-64 vararg func fp reg offset.
381f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman    int BytesToPopOnReturn;           // Number of arg bytes ret should pop.
382f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman
383f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman  public:
384f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman    explicit X86TargetLowering(X86TargetMachine &TM);
385f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman
386f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman    /// getPICBaseSymbol - Return the X86-32 PIC base.
387f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman    MCSymbol *getPICBaseSymbol(const MachineFunction *MF, MCContext &Ctx) const;
388f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman
389b17b08d1f2cdbc3aba28e31755d7a5c3c55e4c3aAnton Korobeynikov    virtual unsigned getJumpTableEncoding() const;
390b17b08d1f2cdbc3aba28e31755d7a5c3c55e4c3aAnton Korobeynikov
3915502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov    virtual const MCExpr *
3925502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov    LowerCustomJumpTableEntry(const MachineJumpTableInfo *MJTI,
3935502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov                              const MachineBasicBlock *MBB, unsigned uid,
394f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman                              MCContext &Ctx) const;
3954198c58c716cbe4516ac3a1a407a3cd52548bc3bAnton Korobeynikov
3965502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov    /// getPICJumpTableRelocaBase - Returns relocation base for the given PIC
3975502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov    /// jumptable.
3985502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov    virtual SDValue getPICJumpTableRelocBase(SDValue Table,
3995502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov                                             SelectionDAG &DAG) const;
400f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman    virtual const MCExpr *
401f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman    getPICJumpTableRelocBaseExpr(const MachineFunction *MF,
4025502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov                                 unsigned JTI, MCContext &Ctx) const;
4034198c58c716cbe4516ac3a1a407a3cd52548bc3bAnton Korobeynikov
4044198c58c716cbe4516ac3a1a407a3cd52548bc3bAnton Korobeynikov    // Return the number of bytes that a function should pop when it returns (in
4054198c58c716cbe4516ac3a1a407a3cd52548bc3bAnton Korobeynikov    // addition to the space used by the return address).
4064198c58c716cbe4516ac3a1a407a3cd52548bc3bAnton Korobeynikov    //
4074198c58c716cbe4516ac3a1a407a3cd52548bc3bAnton Korobeynikov    unsigned getBytesToPopOnReturn() const { return BytesToPopOnReturn; }
4084198c58c716cbe4516ac3a1a407a3cd52548bc3bAnton Korobeynikov
4095502bf67cd49221583c15472150905ce13184d36Anton Korobeynikov    /// getStackPtrReg - Return the stack pointer register we are using: either
410f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman    /// ESP or RSP.
4111c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    unsigned getStackPtrReg() const { return X86StackPtr; }
4121c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
4131c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// getByValTypeAlignment - Return the desired alignment for ByVal aggregate
4141c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// function arguments in the caller parameter area. For X86, aggregates
4151c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// that contains are placed at 16-byte boundaries while the rest are at
4161c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// 4-byte boundaries.
417a69571c7991813c93cba64e88eced6899ce93d81Owen Anderson    virtual unsigned getByValTypeAlignment(const Type *Ty) const;
4185f43f92c69aae9837064cf08291db1b36a82789fDan Gohman
4191c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// getOptimalMemOpType - Returns the target specific optimal type for load
420f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman    /// and store operations as a result of memset, memcpy, and memmove
421f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman    /// lowering. If DstAlign is zero that means it's safe to destination
422f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman    /// alignment can satisfy any constraint. Similarly if SrcAlign is zero it
4233a84b9baf67c938454840d10d9e53269c755cd3eAnton Korobeynikov    /// means there isn't a need to check it against alignment requirement,
4243a84b9baf67c938454840d10d9e53269c755cd3eAnton Korobeynikov    /// probably because the source does not need to be loaded. If
4253a84b9baf67c938454840d10d9e53269c755cd3eAnton Korobeynikov    /// 'NonScalarIntSafe' is true, that means it's safe to return a
4264198c58c716cbe4516ac3a1a407a3cd52548bc3bAnton Korobeynikov    /// non-scalar-integer type, e.g. empty string source, constant, or loaded
427f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman    /// from memory. 'MemcpyStrSrc' indicates whether the memcpy source is
4281c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// constant so it does not need to be loaded.
4291c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// It returns EVT::Other if SelectionDAG should be responsible for
4301c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// determining the type.
431ce2247755e56f99a2377b64a1a9d393726582b85Gordon Henriksen    virtual EVT
432ce2247755e56f99a2377b64a1a9d393726582b85Gordon Henriksen    getOptimalMemOpType(uint64_t Size, unsigned DstAlign, unsigned SrcAlign,
433ce2247755e56f99a2377b64a1a9d393726582b85Gordon Henriksen                        bool NonScalarIntSafe, bool MemcpyStrSrc,
4341c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner                        SelectionDAG &DAG) const;
4351c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
4365f43f92c69aae9837064cf08291db1b36a82789fDan Gohman    /// allowsUnalignedMemoryAccesses - Returns true if the target allows
437ce2247755e56f99a2377b64a1a9d393726582b85Gordon Henriksen    /// unaligned memory accesses. of the specified type.
438ce2247755e56f99a2377b64a1a9d393726582b85Gordon Henriksen    virtual bool allowsUnalignedMemoryAccesses(EVT VT) const {
4395f43f92c69aae9837064cf08291db1b36a82789fDan Gohman      return true;
440ce2247755e56f99a2377b64a1a9d393726582b85Gordon Henriksen    }
4411c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
4421c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// LowerOperation - Provide custom lowering hooks for some operations.
443a651cf67b77cd477dd7da4baa8688af2ccd4f7f6Chris Lattner    ///
444a651cf67b77cd477dd7da4baa8688af2ccd4f7f6Chris Lattner    virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG);
445a651cf67b77cd477dd7da4baa8688af2ccd4f7f6Chris Lattner
446d3948116b81b11e82246c11389a9b4ce7e619fbbChris Lattner    /// ReplaceNodeResults - Replace the results of node with an illegal result
447d3948116b81b11e82246c11389a9b4ce7e619fbbChris Lattner    /// type with new values built out of custom code.
448edf128a7fa90f2b0b7ee24741a04a7ae1ecd6f7eMisha Brukman    ///
449d3948116b81b11e82246c11389a9b4ce7e619fbbChris Lattner    virtual void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results,
450d3948116b81b11e82246c11389a9b4ce7e619fbbChris Lattner                                    SelectionDAG &DAG);
451d3948116b81b11e82246c11389a9b4ce7e619fbbChris Lattner
452d3948116b81b11e82246c11389a9b4ce7e619fbbChris Lattner
453d3948116b81b11e82246c11389a9b4ce7e619fbbChris Lattner    virtual SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const;
454d3948116b81b11e82246c11389a9b4ce7e619fbbChris Lattner
455d3948116b81b11e82246c11389a9b4ce7e619fbbChris Lattner    virtual bool PerformDAGCombinePromotion(SDValue Op, EVT &PVT) const;
456d3948116b81b11e82246c11389a9b4ce7e619fbbChris Lattner
457bd564bfc63163e31f320c3da9749db70992dc35eChris Lattner    virtual MachineBasicBlock *EmitInstrWithCustomInserter(MachineInstr *MI,
458bd564bfc63163e31f320c3da9749db70992dc35eChris Lattner                                                         MachineBasicBlock *MBB,
459d3948116b81b11e82246c11389a9b4ce7e619fbbChris Lattner                    DenseMap<MachineBasicBlock*, MachineBasicBlock*> *EM) const;
460d3948116b81b11e82246c11389a9b4ce7e619fbbChris Lattner
461d3948116b81b11e82246c11389a9b4ce7e619fbbChris Lattner
462a651cf67b77cd477dd7da4baa8688af2ccd4f7f6Chris Lattner    /// getTargetNodeName - This method returns the name of a target specific
463a651cf67b77cd477dd7da4baa8688af2ccd4f7f6Chris Lattner    /// DAG node.
464571e434a34e26f295f13db2dd07551de7e25f8a9Chris Lattner    virtual const char *getTargetNodeName(unsigned Opcode) const;
465571e434a34e26f295f13db2dd07551de7e25f8a9Chris Lattner
4661c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// getSetCCResultType - Return the ISD::SETCC ValueType
4671c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    virtual MVT::SimpleValueType getSetCCResultType(EVT VT) const;
4681c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
4691e7aa5c209109d07af30c8a2e9bfd82cf3824246Chris Lattner    /// computeMaskedBitsForTargetNode - Determine which of the bits specified
4701e7aa5c209109d07af30c8a2e9bfd82cf3824246Chris Lattner    /// in Mask are known to be either zero or one and return them in the
4711c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// KnownZero/KnownOne bitsets.
4721c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    virtual void computeMaskedBitsForTargetNode(const SDValue Op,
4731c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner                                                const APInt &Mask,
4741c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner                                                APInt &KnownZero,
4751c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner                                                APInt &KnownOne,
4761c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner                                                const SelectionDAG &DAG,
4771c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner                                                unsigned Depth = 0) const;
4781c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
4791c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    virtual bool
4801c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    isGAPlusOffset(SDNode *N, const GlobalValue* &GA, int64_t &Offset) const;
4811c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
4821c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    SDValue getReturnAddressFrameIndex(SelectionDAG &DAG);
48328b5b1c7b54c2065882b98af2406c38a3bcee802Chris Lattner
484466685d41a9ea4905b9486fea38e83802e46f196Evan Cheng    virtual bool ExpandInlineAsm(CallInst *CI) const;
48595c218a83ecf77590b9dc40c636720772d2b5cd7Christopher Lamb
4861c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    ConstraintType getConstraintType(const std::string &Constraint) const;
487199862b74973198c2ab5a139f664c86713e7b579Chris Lattner
4881c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    std::vector<unsigned>
4890da331fe0bff24e6c90c706ef8f1f1c3a8d90c2aChris Lattner      getRegClassForInlineAsmConstraint(const std::string &Constraint,
4901c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner                                        EVT VT) const;
4911c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
4920da331fe0bff24e6c90c706ef8f1f1c3a8d90c2aChris Lattner    virtual const char *LowerXConstraint(EVT ConstraintVT) const;
4931c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
4944e4b576e2edfc7d40a3d7177c639acbe91cfd45fChris Lattner    /// LowerAsmOperandForConstraint - Lower the specified operand into the Ops
495e7cf56aeeebed7423402fdf84c5b1aaf6830316eChris Lattner    /// vector.  If it is invalid, don't add anything to Ops. If hasMemory is
496e7cf56aeeebed7423402fdf84c5b1aaf6830316eChris Lattner    /// true it means one of the asm constraint of the inline asm instruction
497e7cf56aeeebed7423402fdf84c5b1aaf6830316eChris Lattner    /// being processed is 'm'.
498f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman    virtual void LowerAsmOperandForConstraint(SDValue Op,
499571e434a34e26f295f13db2dd07551de7e25f8a9Chris Lattner                                              char ConstraintLetter,
500571e434a34e26f295f13db2dd07551de7e25f8a9Chris Lattner                                              bool hasMemory,
501571e434a34e26f295f13db2dd07551de7e25f8a9Chris Lattner                                              std::vector<SDValue> &Ops,
5028c494ab759266322aa05d5e99af9c05eb0d44576Chris Lattner                                              SelectionDAG &DAG) const;
503571e434a34e26f295f13db2dd07551de7e25f8a9Chris Lattner
5046f74b48862948ebb83c7bf7036a76c9e84543fb4Duncan Sands    /// getRegForInlineAsmConstraint - Given a physical register constraint
505070280e97f801ae809ddcc7930c153929f253997Anton Korobeynikov    /// (e.g. {edx}), return the register number and the register class for the
506dc024674ff96820d6020757b48d47f46d4c07db2Duncan Sands    /// register.  This should only be used for C_Register constraints.  On
5071c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// error, this returns a register number of 0.
5081c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    std::pair<unsigned, const TargetRegisterClass*>
5091c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      getRegForInlineAsmConstraint(const std::string &Constraint,
510f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman                                   EVT VT) const;
5111c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
5121c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// isLegalAddressingMode - Return true if the addressing mode represented
513b17b08d1f2cdbc3aba28e31755d7a5c3c55e4c3aAnton Korobeynikov    /// by AM is legal for this target, for a load/store of the specified type.
514dd433210797bc13513989a033e488d4e19442723Anton Korobeynikov    virtual bool isLegalAddressingMode(const AddrMode &AM, const Type *Ty)const;
515b17b08d1f2cdbc3aba28e31755d7a5c3c55e4c3aAnton Korobeynikov
516b17b08d1f2cdbc3aba28e31755d7a5c3c55e4c3aAnton Korobeynikov    /// isTruncateFree - Return true if it's free to truncate a value of
517b17b08d1f2cdbc3aba28e31755d7a5c3c55e4c3aAnton Korobeynikov    /// type Ty1 to type Ty2. e.g. On x86 it's free to truncate a i32 value in
518dd433210797bc13513989a033e488d4e19442723Anton Korobeynikov    /// register EAX to i16 by referencing its sub-register AX.
519b17b08d1f2cdbc3aba28e31755d7a5c3c55e4c3aAnton Korobeynikov    virtual bool isTruncateFree(const Type *Ty1, const Type *Ty2) const;
520b17b08d1f2cdbc3aba28e31755d7a5c3c55e4c3aAnton Korobeynikov    virtual bool isTruncateFree(EVT VT1, EVT VT2) const;
521b17b08d1f2cdbc3aba28e31755d7a5c3c55e4c3aAnton Korobeynikov
522dd433210797bc13513989a033e488d4e19442723Anton Korobeynikov    /// isZExtFree - Return true if any actual instruction that defines a
523b17b08d1f2cdbc3aba28e31755d7a5c3c55e4c3aAnton Korobeynikov    /// value of type Ty1 implicit zero-extends the value to Ty2 in the result
524b17b08d1f2cdbc3aba28e31755d7a5c3c55e4c3aAnton Korobeynikov    /// register. This does not necessarily include registers defined in
525b17b08d1f2cdbc3aba28e31755d7a5c3c55e4c3aAnton Korobeynikov    /// unknown ways, such as incoming arguments, or copies from unknown
5264198c58c716cbe4516ac3a1a407a3cd52548bc3bAnton Korobeynikov    /// virtual registers. Also, if isTruncateFree(Ty2, Ty1) is true, this
5274198c58c716cbe4516ac3a1a407a3cd52548bc3bAnton Korobeynikov    /// does not necessarily apply to truncate instructions. e.g. on x86-64,
5284198c58c716cbe4516ac3a1a407a3cd52548bc3bAnton Korobeynikov    /// all instructions that define 32-bit values implicit zero-extend the
5294198c58c716cbe4516ac3a1a407a3cd52548bc3bAnton Korobeynikov    /// result out to 64 bits.
530f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman    virtual bool isZExtFree(const Type *Ty1, const Type *Ty2) const;
5314198c58c716cbe4516ac3a1a407a3cd52548bc3bAnton Korobeynikov    virtual bool isZExtFree(EVT VT1, EVT VT2) const;
5324198c58c716cbe4516ac3a1a407a3cd52548bc3bAnton Korobeynikov
5334198c58c716cbe4516ac3a1a407a3cd52548bc3bAnton Korobeynikov    /// isNarrowingProfitable - Return true if it's profitable to narrow
5344198c58c716cbe4516ac3a1a407a3cd52548bc3bAnton Korobeynikov    /// operations of type VT1 to VT2. e.g. on x86, it's profitable to narrow
53537efe6764568a3829fee26aba532283131d1a104Nate Begeman    /// from i32 to i8 but not from i32 to i16.
5363a84b9baf67c938454840d10d9e53269c755cd3eAnton Korobeynikov    virtual bool isNarrowingProfitable(EVT VT1, EVT VT2) const;
5373a84b9baf67c938454840d10d9e53269c755cd3eAnton Korobeynikov
538f15485a8d0dff5f720b7ad27346129ac5c3ec503Nate Begeman    /// isFPImmLegal - Returns true if the target can instruction select the
5391c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// specified FP immediate natively. If false, the legalizer will
540b180aa17539e14a5430d020bbc7de83c79b7fc4bJim Laskey    /// materialize the FP immediate as a load from a constant pool.
541b180aa17539e14a5430d020bbc7de83c79b7fc4bJim Laskey    virtual bool isFPImmLegal(const APFloat &Imm, EVT VT) const;
5421c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
5437f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// isShuffleMaskLegal - Targets can use this to indicate that they only
544e21ea61588996609f827213a2701a204f2f13fb3Nate Begeman    /// support *some* VECTOR_SHUFFLE operations, those with specific masks.
5455fbb5d2459a5410590f285250faa604576308a93Nate Begeman    /// By default, if a target supports the VECTOR_SHUFFLE node, all mask
5467f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// values are assumed to be legal.
5477f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    virtual bool isShuffleMaskLegal(const SmallVectorImpl<int> &Mask,
5481628cec4d7fce310d9cde0bcc73997e5a71692c4Reid Spencer                                    EVT VT) const;
5497f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman
55001b3d73c20f5afb8265ae943a8ba23c2238c5eeaChris Lattner    /// isVectorClearMaskLegal - Similar to isShuffleMaskLegal. This is
551b9fccc41933648647e3f7669612c683eb5de0d58Chris Lattner    /// used by Targets can use this to indicate if there is a suitable
5521628cec4d7fce310d9cde0bcc73997e5a71692c4Reid Spencer    /// VECTOR_SHUFFLE that can be used to replace a VAND with a constant
5537f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// pool entry.
5547f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    virtual bool isVectorClearMaskLegal(const SmallVectorImpl<int> &Mask,
5551628cec4d7fce310d9cde0bcc73997e5a71692c4Reid Spencer                                        EVT VT) const;
5567f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman
5571c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// ShouldShrinkFPConstant - If true, then instruction selection should
5587f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// seek to shrink the FP constant of the specified type to a smaller type
5597f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// in order to save space and / or reduce runtime.
5607f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    virtual bool ShouldShrinkFPConstant(EVT VT) const {
5617f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman      // Don't shrink FP constpool if SSE2 is available since cvtss2sd is more
5627f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman      // expensive than a straight movsd. On the other hand, it's important to
5637f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman      // shrink long double fp constant since fldt is very slow.
5647f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman      return !X86ScalarSSEf64 || VT == MVT::f80;
5657f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    }
5667f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman
56724d6da5fedcf39891f7d8c5b031c01324b3db545Reid Spencer    virtual const X86Subtarget* getSubtarget() {
5683822ff5c71478c7c90a50ca57045fb676fcb5005Reid Spencer      return Subtarget;
5693822ff5c71478c7c90a50ca57045fb676fcb5005Reid Spencer    }
57045fb3f3cb2b8efc01d9bbe42a64194f35b92c759Reid Spencer
57145fb3f3cb2b8efc01d9bbe42a64194f35b92c759Reid Spencer    /// isScalarFPTypeInSSEReg - Return true if the specified scalar FP type is
5723da59db637a887474c1b1346c1f3ccf53b6c4663Reid Spencer    /// computed in an SSE register, not on the X87 floating point stack.
5733da59db637a887474c1b1346c1f3ccf53b6c4663Reid Spencer    bool isScalarFPTypeInSSEReg(EVT VT) const {
5743da59db637a887474c1b1346c1f3ccf53b6c4663Reid Spencer      return (VT == MVT::f64 && X86ScalarSSEf64) || // f64 is when SSE2
5753da59db637a887474c1b1346c1f3ccf53b6c4663Reid Spencer      (VT == MVT::f32 && X86ScalarSSEf32);   // f32 is when SSE1
5763da59db637a887474c1b1346c1f3ccf53b6c4663Reid Spencer    }
5773da59db637a887474c1b1346c1f3ccf53b6c4663Reid Spencer
5783da59db637a887474c1b1346c1f3ccf53b6c4663Reid Spencer    /// createFastISel - This method returns a target specific FastISel object,
5793da59db637a887474c1b1346c1f3ccf53b6c4663Reid Spencer    /// or null if the target does not support "fast" ISel.
5803da59db637a887474c1b1346c1f3ccf53b6c4663Reid Spencer    virtual FastISel *
5813da59db637a887474c1b1346c1f3ccf53b6c4663Reid Spencer    createFastISel(MachineFunction &mf,
5823da59db637a887474c1b1346c1f3ccf53b6c4663Reid Spencer                   DenseMap<const Value *, unsigned> &,
5833da59db637a887474c1b1346c1f3ccf53b6c4663Reid Spencer                   DenseMap<const BasicBlock *, MachineBasicBlock *> &,
5843da59db637a887474c1b1346c1f3ccf53b6c4663Reid Spencer                   DenseMap<const AllocaInst *, int> &
5851c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner#ifndef NDEBUG
5862bbd81064a6998496a71ff7ae8160b3caada64faChris Lattner                   , SmallSet<const Instruction *, 8> &
5872bbd81064a6998496a71ff7ae8160b3caada64faChris Lattner#endif
5883e104b11168da4692b69cc6b236c1da22adff959Chris Lattner                   );
589c7029805ef35ce9805931067b841e6af11db382eChris Lattner
5901c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// getFunctionAlignment - Return the Log2 alignment of this function.
5911c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    virtual unsigned getFunctionAlignment(const Function *F) const;
5921c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
5931c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner  private:
5941c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// Subtarget - Keep a pointer to the X86Subtarget around so that we can
5951c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// make the right decision when generating code for different targets.
5961c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    const X86Subtarget *Subtarget;
5971c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    const X86RegisterInfo *RegInfo;
5981c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    const TargetData *TD;
5991c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
600fd7b326bea39c077eea8d378156bcf09051cc4ecDuncan Sands    /// X86StackPtr - X86 physical register used as stack ptr.
601c9ea6fde305b35ab7c9f909ac390d4b53e33d536Chris Lattner    unsigned X86StackPtr;
6020eade319cdb72e24c11d068728a98083737c6435Chris Lattner
6031c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// X86ScalarSSEf32, X86ScalarSSEf64 - Select between SSE or x87
6041c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// floating point ops.
6051c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// When SSE is available, use it for f32 operations.
6061c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// When SSE2 is available, use it for f64 operations.
6071c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    bool X86ScalarSSEf32;
6081c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    bool X86ScalarSSEf64;
6097041ee35adecb864e3e8df490aa73b0605fbfb5aChris Lattner
6101c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// LegalFPImmediates - A list of legal fp immediates.
6111c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    std::vector<APFloat> LegalFPImmediates;
6121c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
6131c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// addLegalFPImmediate - Indicate that this x86 target can instruction
6141c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    /// select the specified FP immediate natively.
6151c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    void addLegalFPImmediate(const APFloat& Imm) {
6161c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner      LegalFPImmediates.push_back(Imm);
6171c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    }
6181c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner
6191c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner    SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
6201c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner                            CallingConv::ID CallConv, bool isVarArg,
6211c08c714bb3d07c3b39f06bfcbb4559fefca73f9Chris Lattner                            const SmallVectorImpl<ISD::InputArg> &Ins,
6226183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                            DebugLoc dl, SelectionDAG &DAG,
6236183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                            SmallVectorImpl<SDValue> &InVals);
6246183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerMemArgument(SDValue Chain,
6256183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                             CallingConv::ID CallConv,
6266183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                             const SmallVectorImpl<ISD::InputArg> &ArgInfo,
6276183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                             DebugLoc dl, SelectionDAG &DAG,
6286183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                             const CCValAssign &VA,  MachineFrameInfo *MFI,
6296183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                              unsigned i);
6306183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerMemOpCallTo(SDValue Chain, SDValue StackPtr, SDValue Arg,
6316183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                             DebugLoc dl, SelectionDAG &DAG,
6326183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                             const CCValAssign &VA,
6336183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                             ISD::ArgFlagsTy Flags);
6346183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman
6356183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    // Call lowering helpers.
6366183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman
6376183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    /// IsEligibleForTailCallOptimization - Check whether the call is eligible
6386183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    /// for tail call optimization. Targets which want to do tail call
639532dc2e1f2473b16b48566c1cbc9eefe94a4e58eDan Gohman    /// optimization should implement this function.
6406183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    bool IsEligibleForTailCallOptimization(SDValue Callee,
6416183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                           CallingConv::ID CalleeCC,
6426183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                           bool isVarArg,
6436183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                           bool isCalleeStructRet,
6446183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                           bool isCallerStructRet,
6456183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                    const SmallVectorImpl<ISD::OutputArg> &Outs,
6466183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                    const SmallVectorImpl<ISD::InputArg> &Ins,
6476183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                           SelectionDAG& DAG) const;
6486183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    bool IsCalleePop(bool isVarArg, CallingConv::ID CallConv);
6496183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue EmitTailCallLoadRetAddr(SelectionDAG &DAG, SDValue &OutRetAddr,
6506183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                SDValue Chain, bool IsTailCall, bool Is64Bit,
651a9b511187b5450ec2e241f45b640358bfdc9c42cDan Gohman                                int FPDiff, DebugLoc dl);
652a9b511187b5450ec2e241f45b640358bfdc9c42cDan Gohman
653a9b511187b5450ec2e241f45b640358bfdc9c42cDan Gohman    CCAssignFn *CCAssignFnForNode(CallingConv::ID CallConv) const;
654a9b511187b5450ec2e241f45b640358bfdc9c42cDan Gohman    unsigned GetAlignedArgumentStackSize(unsigned StackSize, SelectionDAG &DAG);
655a9b511187b5450ec2e241f45b640358bfdc9c42cDan Gohman
656a9b511187b5450ec2e241f45b640358bfdc9c42cDan Gohman    std::pair<SDValue,SDValue> FP_TO_INTHelper(SDValue Op, SelectionDAG &DAG,
657a9b511187b5450ec2e241f45b640358bfdc9c42cDan Gohman                                               bool isSigned);
658a9b511187b5450ec2e241f45b640358bfdc9c42cDan Gohman
659a9b511187b5450ec2e241f45b640358bfdc9c42cDan Gohman    SDValue LowerAsSplatVectorLoad(SDValue SrcOp, EVT VT, DebugLoc dl,
6606183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                   SelectionDAG &DAG);
6616183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG);
6626183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerCONCAT_VECTORS(SDValue Op, SelectionDAG &DAG);
6636183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG);
6646183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG);
6656183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerEXTRACT_VECTOR_ELT_SSE4(SDValue Op, SelectionDAG &DAG);
6666183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG);
6676183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerINSERT_VECTOR_ELT_SSE4(SDValue Op, SelectionDAG &DAG);
6686183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerSCALAR_TO_VECTOR(SDValue Op, SelectionDAG &DAG);
6696183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG);
6706183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG);
6716183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerGlobalAddress(const GlobalValue *GV, DebugLoc dl,
6726183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                               int64_t Offset, SelectionDAG &DAG) const;
6736183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG);
6746183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG);
6756183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerExternalSymbol(SDValue Op, SelectionDAG &DAG);
6766183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerShift(SDValue Op, SelectionDAG &DAG);
6770bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    SDValue BuildFILD(SDValue Op, EVT SrcVT, SDValue Chain, SDValue StackSlot,
6780bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner                      SelectionDAG &DAG);
6796183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerSINT_TO_FP(SDValue Op, SelectionDAG &DAG);
6800bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    SDValue LowerUINT_TO_FP(SDValue Op, SelectionDAG &DAG);
6816183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerUINT_TO_FP_i64(SDValue Op, SelectionDAG &DAG);
6826183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerUINT_TO_FP_i32(SDValue Op, SelectionDAG &DAG);
6836183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerFP_TO_SINT(SDValue Op, SelectionDAG &DAG);
6846183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerFP_TO_UINT(SDValue Op, SelectionDAG &DAG);
6856183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerFABS(SDValue Op, SelectionDAG &DAG);
6866183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerFNEG(SDValue Op, SelectionDAG &DAG);
6876183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerFCOPYSIGN(SDValue Op, SelectionDAG &DAG);
6886183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG);
6896183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerVSETCC(SDValue Op, SelectionDAG &DAG);
6906183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG);
6916183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG);
6926183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerMEMSET(SDValue Op, SelectionDAG &DAG);
6936183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG);
6946183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG);
6956183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG);
6966183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerVAARG(SDValue Op, SelectionDAG &DAG);
6976183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerVACOPY(SDValue Op, SelectionDAG &DAG);
6986183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG);
6996183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG);
7006183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG);
7016183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerFRAME_TO_ARGS_OFFSET(SDValue Op, SelectionDAG &DAG);
7026183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerEH_RETURN(SDValue Op, SelectionDAG &DAG);
7036183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerTRAMPOLINE(SDValue Op, SelectionDAG &DAG);
7046183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerFLT_ROUNDS_(SDValue Op, SelectionDAG &DAG);
7056183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerCTLZ(SDValue Op, SelectionDAG &DAG);
706532dc2e1f2473b16b48566c1cbc9eefe94a4e58eDan Gohman    SDValue LowerCTTZ(SDValue Op, SelectionDAG &DAG);
7076183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerMUL_V2I64(SDValue Op, SelectionDAG &DAG);
7086183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerXALUO(SDValue Op, SelectionDAG &DAG);
7096183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman
710be444ed6dbc2a6f36feab84b527a21aa0df9f808Dan Gohman    SDValue LowerCMP_SWAP(SDValue Op, SelectionDAG &DAG);
7116183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue LowerLOAD_SUB(SDValue Op, SelectionDAG &DAG);
712be444ed6dbc2a6f36feab84b527a21aa0df9f808Dan Gohman    SDValue LowerREADCYCLECOUNTER(SDValue Op, SelectionDAG &DAG);
7136183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman
7146183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    virtual SDValue
715532dc2e1f2473b16b48566c1cbc9eefe94a4e58eDan Gohman      LowerFormalArguments(SDValue Chain,
7166183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                           CallingConv::ID CallConv, bool isVarArg,
7176183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                           const SmallVectorImpl<ISD::InputArg> &Ins,
7186183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                           DebugLoc dl, SelectionDAG &DAG,
7196183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                           SmallVectorImpl<SDValue> &InVals);
7206183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    virtual SDValue
7216183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman      LowerCall(SDValue Chain, SDValue Callee,
7226183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                CallingConv::ID CallConv, bool isVarArg, bool &isTailCall,
723be444ed6dbc2a6f36feab84b527a21aa0df9f808Dan Gohman                const SmallVectorImpl<ISD::OutputArg> &Outs,
7246183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                const SmallVectorImpl<ISD::InputArg> &Ins,
7256183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                DebugLoc dl, SelectionDAG &DAG,
7266183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                SmallVectorImpl<SDValue> &InVals);
7276183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman
7286183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    virtual SDValue
7296183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman      LowerReturn(SDValue Chain,
7306183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                  CallingConv::ID CallConv, bool isVarArg,
7316183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                  const SmallVectorImpl<ISD::OutputArg> &Outs,
732532dc2e1f2473b16b48566c1cbc9eefe94a4e58eDan Gohman                  DebugLoc dl, SelectionDAG &DAG);
73325ac7e8364f475597e2a6f3628fce839583e1f45Dan Gohman
73425ac7e8364f475597e2a6f3628fce839583e1f45Dan Gohman    virtual bool
7356183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman      CanLowerReturn(CallingConv::ID CallConv, bool isVarArg,
7366183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                     const SmallVectorImpl<EVT> &OutTys,
7376183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                     const SmallVectorImpl<ISD::ArgFlagsTy> &ArgsFlags,
7386183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                     SelectionDAG &DAG);
7396183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman
7406183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    void ReplaceATOMIC_BINARY_64(SDNode *N, SmallVectorImpl<SDValue> &Results,
7416183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                 SelectionDAG &DAG, unsigned NewOp);
74225ac7e8364f475597e2a6f3628fce839583e1f45Dan Gohman
743532dc2e1f2473b16b48566c1cbc9eefe94a4e58eDan Gohman    SDValue EmitTargetCodeForMemset(SelectionDAG &DAG, DebugLoc dl,
7446183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                    SDValue Chain,
7456183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                    SDValue Dst, SDValue Src,
7466183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                    SDValue Size, unsigned Align,
7476183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                    bool isVolatile,
7486183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                    const Value *DstSV, uint64_t DstSVOff);
7496183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl,
7506183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                    SDValue Chain,
7516183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                    SDValue Dst, SDValue Src,
7526183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                    SDValue Size, unsigned Align,
7536183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                    bool isVolatile, bool AlwaysInline,
7546183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                    const Value *DstSV, uint64_t DstSVOff,
755a9b511187b5450ec2e241f45b640358bfdc9c42cDan Gohman                                    const Value *SrcSV, uint64_t SrcSVOff);
756a9b511187b5450ec2e241f45b640358bfdc9c42cDan Gohman
757a9b511187b5450ec2e241f45b640358bfdc9c42cDan Gohman    /// Utility function to emit string processing sse4.2 instructions
758a9b511187b5450ec2e241f45b640358bfdc9c42cDan Gohman    /// that return in xmm0.
759a9b511187b5450ec2e241f45b640358bfdc9c42cDan Gohman    /// This takes the instruction to expand, the associated machine basic
760a9b511187b5450ec2e241f45b640358bfdc9c42cDan Gohman    /// block, the number of args, and whether or not the second arg is
761a9b511187b5450ec2e241f45b640358bfdc9c42cDan Gohman    /// in memory or not.
7626183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    MachineBasicBlock *EmitPCMP(MachineInstr *BInstr, MachineBasicBlock *BB,
7636183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                unsigned argNum, bool inMem) const;
7646183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman
7656183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    /// Utility function to emit atomic bitwise operations (and, or, xor).
7666183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    /// It takes the bitwise instruction to expand, the associated machine basic
7676183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    /// block, and the associated X86 opcodes for reg/reg and reg/imm.
7686183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    MachineBasicBlock *EmitAtomicBitwiseWithCustomInserter(
7696183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                                    MachineInstr *BInstr,
7706183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                                    MachineBasicBlock *BB,
7716183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                                    unsigned regOpc,
7726183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                                    unsigned immOpc,
7736183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                                    unsigned loadOpc,
7746183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                                    unsigned cxchgOpc,
7756183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                                    unsigned copyOpc,
7766183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                                    unsigned notOpc,
7776183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                                    unsigned EAXreg,
7786183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                                    TargetRegisterClass *RC,
7796183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                                    bool invSrc = false) const;
7806183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman
7816183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    MachineBasicBlock *EmitAtomicBit6432WithCustomInserter(
7826183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                                    MachineInstr *BInstr,
7836183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                                    MachineBasicBlock *BB,
7846183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                                    unsigned regOpcL,
7856183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                                    unsigned regOpcH,
7866183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                                    unsigned immOpcL,
7876183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                                    unsigned immOpcH,
7886183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                                    bool invSrc = false) const;
7896183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman
7906183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    /// Utility function to emit atomic min and max.  It takes the min/max
7916183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    /// instruction to expand, the associated basic block, and the associated
7926183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    /// cmov opcode for moving the min or max value.
7936183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    MachineBasicBlock *EmitAtomicMinMaxWithCustomInserter(MachineInstr *BInstr,
7946183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                                          MachineBasicBlock *BB,
7956183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                                        unsigned cmovOpc) const;
7966183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman
7976183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    /// Utility function to emit the xmm reg save portion of va_start.
7986183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    MachineBasicBlock *EmitVAStartSaveXMMRegsWithCustomInserter(
7996183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                                   MachineInstr *BInstr,
80025ac7e8364f475597e2a6f3628fce839583e1f45Dan Gohman                                                   MachineBasicBlock *BB) const;
8016183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman
8026183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    MachineBasicBlock *EmitLoweredSelect(MachineInstr *I,
8036183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                         MachineBasicBlock *BB,
80425ac7e8364f475597e2a6f3628fce839583e1f45Dan Gohman                    DenseMap<MachineBasicBlock*, MachineBasicBlock*> *EM) const;
8056183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman
8066183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    MachineBasicBlock *EmitLoweredMingwAlloca(MachineInstr *MI,
8076183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                                              MachineBasicBlock *BB,
8086183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                    DenseMap<MachineBasicBlock*, MachineBasicBlock*> *EM) const;
8096183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman
8106183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    /// Emit nodes that will be selected as "test Op0,Op0", or something
811532dc2e1f2473b16b48566c1cbc9eefe94a4e58eDan Gohman    /// equivalent, for use with the given x86 condition code.
8126183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue EmitTest(SDValue Op0, unsigned X86CC, SelectionDAG &DAG);
8136183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman
8146183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    /// Emit nodes that will be selected as "cmp Op0,Op1", or something
8156183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    /// equivalent, for use with the given x86 condition code.
8166183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    SDValue EmitCmp(SDValue Op0, SDValue Op1, unsigned X86CC,
8176183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                    SelectionDAG &DAG);
8186183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman  };
819532dc2e1f2473b16b48566c1cbc9eefe94a4e58eDan Gohman
8206183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman  namespace X86 {
8216183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman    FastISel *createFastISel(MachineFunction &mf,
8226183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                           DenseMap<const Value *, unsigned> &,
8236183f78cf8c6f56cc436f19120acf2a7856cb9dbDan Gohman                           DenseMap<const BasicBlock *, MachineBasicBlock *> &,
824199862b74973198c2ab5a139f664c86713e7b579Chris Lattner                           DenseMap<const AllocaInst *, int> &
825199862b74973198c2ab5a139f664c86713e7b579Chris Lattner#ifndef NDEBUG
826199862b74973198c2ab5a139f664c86713e7b579Chris Lattner                           , SmallSet<const Instruction*, 8> &
827199862b74973198c2ab5a139f664c86713e7b579Chris Lattner#endif
828199862b74973198c2ab5a139f664c86713e7b579Chris Lattner                           );
829199862b74973198c2ab5a139f664c86713e7b579Chris Lattner  }
830199862b74973198c2ab5a139f664c86713e7b579Chris Lattner}
831199862b74973198c2ab5a139f664c86713e7b579Chris Lattner
832199862b74973198c2ab5a139f664c86713e7b579Chris Lattner#endif    // X86ISELLOWERING_H
8330da331fe0bff24e6c90c706ef8f1f1c3a8d90c2aChris Lattner