X86ISelLowering.h revision a375d471378b1674a9d77d180a0b05ea8c90cb4b
1dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner//===-- X86ISelLowering.h - X86 DAG Lowering Interface ----------*- C++ -*-===//
2dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner//
3dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner//                     The LLVM Compiler Infrastructure
4dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner//
54ee451de366474b9c228b4e5fa573795a715216dChris Lattner// This file is distributed under the University of Illinois Open Source
64ee451de366474b9c228b4e5fa573795a715216dChris Lattner// License. See LICENSE.TXT for details.
7dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner//
8dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner//===----------------------------------------------------------------------===//
9dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner//
10dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner// This file defines the interfaces that X86 uses to lower LLVM code into a
11dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner// selection DAG.
12dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner//
13dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner//===----------------------------------------------------------------------===//
14dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner
15dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner#ifndef X86ISELLOWERING_H
16dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner#define X86ISELLOWERING_H
17dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner
18559806f575297866609c7bef0e5c1084dcdda9a5Evan Cheng#include "X86Subtarget.h"
192365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov#include "X86RegisterInfo.h"
2086737665b81550fdb575f7d8cc5decc801a7813dGordon Henriksen#include "X86MachineFunctionInfo.h"
21dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner#include "llvm/Target/TargetLowering.h"
22ddc419c581ac827045d614099adaa60765ce1ebeEvan Cheng#include "llvm/Target/TargetOptions.h"
23b388eb82fb4a95e2f6d54163dfcf962b8032bae8Ted Kremenek#include "llvm/CodeGen/FastISel.h"
24dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner#include "llvm/CodeGen/SelectionDAG.h"
251b5dcc34b701639f94008658a2042abc43b9b910Rafael Espindola#include "llvm/CodeGen/CallingConvLower.h"
26dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner
27dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattnernamespace llvm {
28dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner  namespace X86ISD {
29d9558e0ba6ddcf2798cfb88cc56e5f1c8135eb0dEvan Cheng    // X86 Specific DAG Nodes
30dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner    enum NodeType {
31dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner      // Start the numbering where the builtin ops leave off.
320ba2bcfcc3149a25d08aa8aa00fb6c34a4e25bddDan Gohman      FIRST_NUMBER = ISD::BUILTIN_OP_END,
33dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner
3418efe269b12624d74c0af6104e88864d6a932344Evan Cheng      /// BSF - Bit scan forward.
3518efe269b12624d74c0af6104e88864d6a932344Evan Cheng      /// BSR - Bit scan reverse.
3618efe269b12624d74c0af6104e88864d6a932344Evan Cheng      BSF,
3718efe269b12624d74c0af6104e88864d6a932344Evan Cheng      BSR,
3818efe269b12624d74c0af6104e88864d6a932344Evan Cheng
39e3413160ca2fb42854b2a23be6b2114c1da2778cEvan Cheng      /// SHLD, SHRD - Double shift instructions. These correspond to
40e3413160ca2fb42854b2a23be6b2114c1da2778cEvan Cheng      /// X86::SHLDxx and X86::SHRDxx instructions.
41e3413160ca2fb42854b2a23be6b2114c1da2778cEvan Cheng      SHLD,
42e3413160ca2fb42854b2a23be6b2114c1da2778cEvan Cheng      SHRD,
43e3413160ca2fb42854b2a23be6b2114c1da2778cEvan Cheng
44ef6ffb17c71232af5962f9926b31508eb942cddcEvan Cheng      /// FAND - Bitwise logical AND of floating point values. This corresponds
45ef6ffb17c71232af5962f9926b31508eb942cddcEvan Cheng      /// to X86::ANDPS or X86::ANDPD.
46ef6ffb17c71232af5962f9926b31508eb942cddcEvan Cheng      FAND,
47ef6ffb17c71232af5962f9926b31508eb942cddcEvan Cheng
4868c47cba3589b2fc079bab0836d1ae6fc3a6278dEvan Cheng      /// FOR - Bitwise logical OR of floating point values. This corresponds
4968c47cba3589b2fc079bab0836d1ae6fc3a6278dEvan Cheng      /// to X86::ORPS or X86::ORPD.
5068c47cba3589b2fc079bab0836d1ae6fc3a6278dEvan Cheng      FOR,
5168c47cba3589b2fc079bab0836d1ae6fc3a6278dEvan Cheng
52223547ab3101f32252cb704a67bd757e00fdbd16Evan Cheng      /// FXOR - Bitwise logical XOR of floating point values. This corresponds
53223547ab3101f32252cb704a67bd757e00fdbd16Evan Cheng      /// to X86::XORPS or X86::XORPD.
54223547ab3101f32252cb704a67bd757e00fdbd16Evan Cheng      FXOR,
55223547ab3101f32252cb704a67bd757e00fdbd16Evan Cheng
5673d6cf12adfd915897cce7e1ba9de00f962502d5Evan Cheng      /// FSRL - Bitwise logical right shift of floating point values. These
5773d6cf12adfd915897cce7e1ba9de00f962502d5Evan Cheng      /// corresponds to X86::PSRLDQ.
5868c47cba3589b2fc079bab0836d1ae6fc3a6278dEvan Cheng      FSRL,
5968c47cba3589b2fc079bab0836d1ae6fc3a6278dEvan Cheng
60e3de85b447b0a94c82f147159a0c903ea47e0069Evan Cheng      /// FILD, FILD_FLAG - This instruction implements SINT_TO_FP with the
61e3de85b447b0a94c82f147159a0c903ea47e0069Evan Cheng      /// integer source in memory and FP reg result.  This corresponds to the
62e3de85b447b0a94c82f147159a0c903ea47e0069Evan Cheng      /// X86::FILD*m instructions. It has three inputs (token chain, address,
63e3de85b447b0a94c82f147159a0c903ea47e0069Evan Cheng      /// and source type) and two outputs (FP value and token chain). FILD_FLAG
64e3de85b447b0a94c82f147159a0c903ea47e0069Evan Cheng      /// also produces a flag).
65a3195e86439896ecba9b3f2afce40919b20a987aEvan Cheng      FILD,
66e3de85b447b0a94c82f147159a0c903ea47e0069Evan Cheng      FILD_FLAG,
67dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner
68dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner      /// FP_TO_INT*_IN_MEM - This instruction implements FP_TO_SINT with the
69dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner      /// integer destination in memory and a FP reg source.  This corresponds
70dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner      /// to the X86::FIST*m instructions and the rounding mode change stuff. It
7191897778690a7d683497ba3f4040ebf09345f08aChris Lattner      /// has two inputs (token chain and address) and two outputs (int value
7291897778690a7d683497ba3f4040ebf09345f08aChris Lattner      /// and token chain).
73dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner      FP_TO_INT16_IN_MEM,
74dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner      FP_TO_INT32_IN_MEM,
75dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner      FP_TO_INT64_IN_MEM,
76dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner
77b077b842b64af39c8e2e9aaad327b3be446790ddEvan Cheng      /// FLD - This instruction implements an extending load to FP stack slots.
78b077b842b64af39c8e2e9aaad327b3be446790ddEvan Cheng      /// This corresponds to the X86::FLD32m / X86::FLD64m. It takes a chain
7938bcbaf23e8836c8f64e7fd66ebebc44a2b921a1Evan Cheng      /// operand, ptr to load from, and a ValueType node indicating the type
8038bcbaf23e8836c8f64e7fd66ebebc44a2b921a1Evan Cheng      /// to load to.
81b077b842b64af39c8e2e9aaad327b3be446790ddEvan Cheng      FLD,
82b077b842b64af39c8e2e9aaad327b3be446790ddEvan Cheng
83d90eb7fb2435e2abedb4694edc44fa45642edbe9Evan Cheng      /// FST - This instruction implements a truncating store to FP stack
84d90eb7fb2435e2abedb4694edc44fa45642edbe9Evan Cheng      /// slots. This corresponds to the X86::FST32m / X86::FST64m. It takes a
85d90eb7fb2435e2abedb4694edc44fa45642edbe9Evan Cheng      /// chain operand, value to store, address, and a ValueType to store it
86d90eb7fb2435e2abedb4694edc44fa45642edbe9Evan Cheng      /// as.
87d90eb7fb2435e2abedb4694edc44fa45642edbe9Evan Cheng      FST,
88d90eb7fb2435e2abedb4694edc44fa45642edbe9Evan Cheng
8998ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman      /// CALL - These operations represent an abstract X86 call
90dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner      /// instruction, which includes a bunch of information.  In particular the
91dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner      /// operands of these node are:
92dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner      ///
93dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner      ///     #0 - The incoming token chain
94dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner      ///     #1 - The callee
95dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner      ///     #2 - The number of arg bytes the caller pushes on the stack.
96dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner      ///     #3 - The number of arg bytes the callee pops off the stack.
97dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner      ///     #4 - The value to pass in AL/AX/EAX (optional)
98dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner      ///     #5 - The value to pass in DL/DX/EDX (optional)
99dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner      ///
100dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner      /// The result values of these nodes are:
101dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner      ///
102dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner      ///     #0 - The outgoing token chain
103dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner      ///     #1 - The first register result value (optional)
104dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner      ///     #2 - The second register result value (optional)
105dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner      ///
106dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner      CALL,
10798ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman
108b873ff322c28ce097762355921100b677c71238dAndrew Lenharth      /// RDTSC_DAG - This operation implements the lowering for
109b873ff322c28ce097762355921100b677c71238dAndrew Lenharth      /// readcyclecounter
110b873ff322c28ce097762355921100b677c71238dAndrew Lenharth      RDTSC_DAG,
1117df96d66729d1f33934de7b52553e5f071686041Evan Cheng
1127df96d66729d1f33934de7b52553e5f071686041Evan Cheng      /// X86 compare and logical compare instructions.
1137d6ff3a25d9be6fae7ad95837ba8f1a8738947b6Evan Cheng      CMP, COMI, UCOMI,
1147df96d66729d1f33934de7b52553e5f071686041Evan Cheng
115c7a37d4ff2ee8ffb93ba97e9393ff582f0e79a9aDan Gohman      /// X86 bit-test instructions.
116c7a37d4ff2ee8ffb93ba97e9393ff582f0e79a9aDan Gohman      BT,
117c7a37d4ff2ee8ffb93ba97e9393ff582f0e79a9aDan Gohman
1182004eb6272d4787b9e08a83230fe022cbaf4deb0Dan Gohman      /// X86 SetCC. Operand 0 is condition code, and operand 1 is the flag
119d5781fca4f8f98863560338d4f8d017389428119Evan Cheng      /// operand produced by a CMP instruction.
120d5781fca4f8f98863560338d4f8d017389428119Evan Cheng      SETCC,
121d5781fca4f8f98863560338d4f8d017389428119Evan Cheng
122ad9c0a3d8bf625d169596547f893b9ec8b953e26Evan Cheng      // Same as SETCC except it's materialized with a sbb and the value is all
123ad9c0a3d8bf625d169596547f893b9ec8b953e26Evan Cheng      // one's or all zero's.
124ad9c0a3d8bf625d169596547f893b9ec8b953e26Evan Cheng      SETCC_CARRY,
125ad9c0a3d8bf625d169596547f893b9ec8b953e26Evan Cheng
1262b9f4349086247c58ed0bcd17c7d11b14b14f52bChris Lattner      /// X86 conditional moves. Operand 0 and operand 1 are the two values
1272b9f4349086247c58ed0bcd17c7d11b14b14f52bChris Lattner      /// to select from. Operand 2 is the condition code, and operand 3 is the
1282b9f4349086247c58ed0bcd17c7d11b14b14f52bChris Lattner      /// flag operand produced by a CMP or TEST instruction. It also writes a
1292b9f4349086247c58ed0bcd17c7d11b14b14f52bChris Lattner      /// flag result.
1307df96d66729d1f33934de7b52553e5f071686041Evan Cheng      CMOV,
131898101c15fa11a896deb4e2fcb73b4727e1dcc1fEvan Cheng
1322004eb6272d4787b9e08a83230fe022cbaf4deb0Dan Gohman      /// X86 conditional branches. Operand 0 is the chain operand, operand 1
1332004eb6272d4787b9e08a83230fe022cbaf4deb0Dan Gohman      /// is the block to branch if condition is true, operand 2 is the
1342004eb6272d4787b9e08a83230fe022cbaf4deb0Dan Gohman      /// condition code, and operand 3 is the flag operand produced by a CMP
135d5781fca4f8f98863560338d4f8d017389428119Evan Cheng      /// or TEST instruction.
136898101c15fa11a896deb4e2fcb73b4727e1dcc1fEvan Cheng      BRCOND,
137b077b842b64af39c8e2e9aaad327b3be446790ddEvan Cheng
1382004eb6272d4787b9e08a83230fe022cbaf4deb0Dan Gohman      /// Return with a flag operand. Operand 0 is the chain operand, operand
1392004eb6272d4787b9e08a83230fe022cbaf4deb0Dan Gohman      /// 1 is the number of bytes of stack to pop.
140b077b842b64af39c8e2e9aaad327b3be446790ddEvan Cheng      RET_FLAG,
14167f92a76497d1f50e0dd6279c81b45689bd463f5Evan Cheng
14267f92a76497d1f50e0dd6279c81b45689bd463f5Evan Cheng      /// REP_STOS - Repeat fill, corresponds to X86::REP_STOSx.
14367f92a76497d1f50e0dd6279c81b45689bd463f5Evan Cheng      REP_STOS,
14467f92a76497d1f50e0dd6279c81b45689bd463f5Evan Cheng
14567f92a76497d1f50e0dd6279c81b45689bd463f5Evan Cheng      /// REP_MOVS - Repeat move, corresponds to X86::REP_MOVSx.
14667f92a76497d1f50e0dd6279c81b45689bd463f5Evan Cheng      REP_MOVS,
147223547ab3101f32252cb704a67bd757e00fdbd16Evan Cheng
1487ccced634ae0ecdc1c4f599fd3abf188c367e231Evan Cheng      /// GlobalBaseReg - On Darwin, this node represents the result of the popl
1497ccced634ae0ecdc1c4f599fd3abf188c367e231Evan Cheng      /// at function entry, used for PIC code.
1507ccced634ae0ecdc1c4f599fd3abf188c367e231Evan Cheng      GlobalBaseReg,
151a0ea0539e359f6d82218e5aa4cdf3b50b17d6fbdEvan Cheng
152056292fd738924f3f7703725d8f630983794b5a5Bill Wendling      /// Wrapper - A wrapper node for TargetConstantPool,
153056292fd738924f3f7703725d8f630983794b5a5Bill Wendling      /// TargetExternalSymbol, and TargetGlobalAddress.
154020d2e8e7aa36692af13c1215fdd6248a6d9e950Evan Cheng      Wrapper,
15548090aa8145640c023563751a8a1e1bcc09125e5Evan Cheng
1560085a28d13f86b09ba0c83e8dce81de3ba15ca2dEvan Cheng      /// WrapperRIP - Special wrapper used under X86-64 PIC mode for RIP
1570085a28d13f86b09ba0c83e8dce81de3ba15ca2dEvan Cheng      /// relative displacements.
1580085a28d13f86b09ba0c83e8dce81de3ba15ca2dEvan Cheng      WrapperRIP,
1590085a28d13f86b09ba0c83e8dce81de3ba15ca2dEvan Cheng
160eb38ebf15c326a5bb45ca9da6329cdf19ad6df95Mon P Wang      /// MOVQ2DQ - Copies a 64-bit value from a vector to another vector.
161eb38ebf15c326a5bb45ca9da6329cdf19ad6df95Mon P Wang      /// Can be used to move a vector value from a MMX register to a XMM
162eb38ebf15c326a5bb45ca9da6329cdf19ad6df95Mon P Wang      /// register.
163eb38ebf15c326a5bb45ca9da6329cdf19ad6df95Mon P Wang      MOVQ2DQ,
164eb38ebf15c326a5bb45ca9da6329cdf19ad6df95Mon P Wang
16514d12caf1d2de9618818646d12b30d647a860817Nate Begeman      /// PEXTRB - Extract an 8-bit value from a vector and zero extend it to
16614d12caf1d2de9618818646d12b30d647a860817Nate Begeman      /// i32, corresponds to X86::PEXTRB.
16714d12caf1d2de9618818646d12b30d647a860817Nate Begeman      PEXTRB,
16814d12caf1d2de9618818646d12b30d647a860817Nate Begeman
169b067a1e7e68c4446d3512c25d3a5ac55c6dd76f8Evan Cheng      /// PEXTRW - Extract a 16-bit value from a vector and zero extend it to
170653159f4aac61a7ad796e406a4899d27ffe5a789Evan Cheng      /// i32, corresponds to X86::PEXTRW.
171b067a1e7e68c4446d3512c25d3a5ac55c6dd76f8Evan Cheng      PEXTRW,
172653159f4aac61a7ad796e406a4899d27ffe5a789Evan Cheng
17314d12caf1d2de9618818646d12b30d647a860817Nate Begeman      /// INSERTPS - Insert any element of a 4 x float vector into any element
17414d12caf1d2de9618818646d12b30d647a860817Nate Begeman      /// of a destination 4 x floatvector.
17514d12caf1d2de9618818646d12b30d647a860817Nate Begeman      INSERTPS,
17614d12caf1d2de9618818646d12b30d647a860817Nate Begeman
17714d12caf1d2de9618818646d12b30d647a860817Nate Begeman      /// PINSRB - Insert the lower 8-bits of a 32-bit value to a vector,
17814d12caf1d2de9618818646d12b30d647a860817Nate Begeman      /// corresponds to X86::PINSRB.
17914d12caf1d2de9618818646d12b30d647a860817Nate Begeman      PINSRB,
18014d12caf1d2de9618818646d12b30d647a860817Nate Begeman
181653159f4aac61a7ad796e406a4899d27ffe5a789Evan Cheng      /// PINSRW - Insert the lower 16-bits of a 32-bit value to a vector,
182653159f4aac61a7ad796e406a4899d27ffe5a789Evan Cheng      /// corresponds to X86::PINSRW.
1838f2b4cc07161b56e56d6615761ea4ba08dc0e7d3Chris Lattner      PINSRW, MMX_PINSRW,
1848ca29326e19201075f6dc95781560ea9ad41ececEvan Cheng
185b9a47b824f6c8ef3989a796018bf974c09cd243fNate Begeman      /// PSHUFB - Shuffle 16 8-bit values within a vector.
186b9a47b824f6c8ef3989a796018bf974c09cd243fNate Begeman      PSHUFB,
187b9a47b824f6c8ef3989a796018bf974c09cd243fNate Begeman
1888ca29326e19201075f6dc95781560ea9ad41ececEvan Cheng      /// FMAX, FMIN - Floating point max and min.
1898ca29326e19201075f6dc95781560ea9ad41ececEvan Cheng      ///
190b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio      FMAX, FMIN,
1912038252c6a36efd18cc0bef216fa2c5bb9236617Dan Gohman
1922038252c6a36efd18cc0bef216fa2c5bb9236617Dan Gohman      /// FRSQRT, FRCP - Floating point reciprocal-sqrt and reciprocal
1932038252c6a36efd18cc0bef216fa2c5bb9236617Dan Gohman      /// approximation.  Note that these typically require refinement
1942038252c6a36efd18cc0bef216fa2c5bb9236617Dan Gohman      /// in order to obtain suitable precision.
1952038252c6a36efd18cc0bef216fa2c5bb9236617Dan Gohman      FRSQRT, FRCP,
1962038252c6a36efd18cc0bef216fa2c5bb9236617Dan Gohman
197094fad37b90946c91a09eb9270a0dbe800f49d87Rafael Espindola      // TLSADDR - Thread Local Storage.
198094fad37b90946c91a09eb9270a0dbe800f49d87Rafael Espindola      TLSADDR,
199094fad37b90946c91a09eb9270a0dbe800f49d87Rafael Espindola
200094fad37b90946c91a09eb9270a0dbe800f49d87Rafael Espindola      // SegmentBaseAddress - The address segment:0
201094fad37b90946c91a09eb9270a0dbe800f49d87Rafael Espindola      SegmentBaseAddress,
2022365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov
2037e2ff77ef05c23db6b9c82bc7a4110e170d7f94cEvan Cheng      // EH_RETURN - Exception Handling helpers.
204c85e1716f0e45e4c18a9ef2fbe431a51ac3a4252Arnold Schwaighofer      EH_RETURN,
205c85e1716f0e45e4c18a9ef2fbe431a51ac3a4252Arnold Schwaighofer
2064fe3073cfb5273a3655aef0c8d50c96882f26882Arnold Schwaighofer      /// TC_RETURN - Tail call return.
2074fe3073cfb5273a3655aef0c8d50c96882f26882Arnold Schwaighofer      ///   operand #0 chain
2084fe3073cfb5273a3655aef0c8d50c96882f26882Arnold Schwaighofer      ///   operand #1 callee (register or absolute)
2094fe3073cfb5273a3655aef0c8d50c96882f26882Arnold Schwaighofer      ///   operand #2 stack adjustment
2104fe3073cfb5273a3655aef0c8d50c96882f26882Arnold Schwaighofer      ///   operand #3 optional in flag
21145b22fa9f1f085d7971cce6db4f11b353e1646c6Anton Korobeynikov      TC_RETURN,
21245b22fa9f1f085d7971cce6db4f11b353e1646c6Anton Korobeynikov
2137e2ff77ef05c23db6b9c82bc7a4110e170d7f94cEvan Cheng      // LCMPXCHG_DAG, LCMPXCHG8_DAG - Compare and swap.
21426ed8697d4733f4ad588ef117ec4387560770ad0Andrew Lenharth      LCMPXCHG_DAG,
215d19189e9905e14a4001a8ca6fc4effb6a3f88e45Andrew Lenharth      LCMPXCHG8_DAG,
21626ed8697d4733f4ad588ef117ec4387560770ad0Andrew Lenharth
2177e2ff77ef05c23db6b9c82bc7a4110e170d7f94cEvan Cheng      // FNSTCW16m - Store FP control world into i16 memory.
2187e2ff77ef05c23db6b9c82bc7a4110e170d7f94cEvan Cheng      FNSTCW16m,
2197e2ff77ef05c23db6b9c82bc7a4110e170d7f94cEvan Cheng
220d880b97257c7f8ec4e94948874cb87c865d9f96fEvan Cheng      // VZEXT_MOVL - Vector move low and zero extend.
221d880b97257c7f8ec4e94948874cb87c865d9f96fEvan Cheng      VZEXT_MOVL,
222d880b97257c7f8ec4e94948874cb87c865d9f96fEvan Cheng
223d880b97257c7f8ec4e94948874cb87c865d9f96fEvan Cheng      // VZEXT_LOAD - Load, scalar_to_vector, and zero extend.
224f26ffe987cf3643a7bd66bd9f97c34605ba7d08eEvan Cheng      VZEXT_LOAD,
225f26ffe987cf3643a7bd66bd9f97c34605ba7d08eEvan Cheng
226f26ffe987cf3643a7bd66bd9f97c34605ba7d08eEvan Cheng      // VSHL, VSRL - Vector logical left / right shift.
22730a0de94e7a5cbdcd277a93e543b0788efa78ddcNate Begeman      VSHL, VSRL,
2289008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman
2299008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman      // CMPPD, CMPPS - Vector double/float comparison.
23030a0de94e7a5cbdcd277a93e543b0788efa78ddcNate Begeman      // CMPPD, CMPPS - Vector double/float comparison.
23130a0de94e7a5cbdcd277a93e543b0788efa78ddcNate Begeman      CMPPD, CMPPS,
23230a0de94e7a5cbdcd277a93e543b0788efa78ddcNate Begeman
23330a0de94e7a5cbdcd277a93e543b0788efa78ddcNate Begeman      // PCMP* - Vector integer comparisons.
23430a0de94e7a5cbdcd277a93e543b0788efa78ddcNate Begeman      PCMPEQB, PCMPEQW, PCMPEQD, PCMPEQQ,
235ab55ebda1c2254f98b06e770bc2dae7d05a4a366Bill Wendling      PCMPGTB, PCMPGTW, PCMPGTD, PCMPGTQ,
236ab55ebda1c2254f98b06e770bc2dae7d05a4a366Bill Wendling
237076aee32e86bc4a0c096262b3261923f25220dc6Dan Gohman      // ADD, SUB, SMUL, UMUL, etc. - Arithmetic operations with FLAGS results.
238076aee32e86bc4a0c096262b3261923f25220dc6Dan Gohman      ADD, SUB, SMUL, UMUL,
239e220c4b3d97bbdc9f6e8cf040942514612349c41Dan Gohman      INC, DEC, OR, XOR, AND,
24073f24c9f0d9afd1fd65d544f2b7b7b7c77fc2238Evan Cheng
24173f24c9f0d9afd1fd65d544f2b7b7b7c77fc2238Evan Cheng      // MUL_IMM - X86 specific multiply by immediate.
24271c6753d03d1bb27d0cf997285c425d631e5807bEric Christopher      MUL_IMM,
24371c6753d03d1bb27d0cf997285c425d631e5807bEric Christopher
24471c6753d03d1bb27d0cf997285c425d631e5807bEric Christopher      // PTEST - Vector bitwise comparisons
245d6708eade079c30b0790789a00a8d737d84f52b7Dan Gohman      PTEST,
246d6708eade079c30b0790789a00a8d737d84f52b7Dan Gohman
247d6708eade079c30b0790789a00a8d737d84f52b7Dan Gohman      // VASTART_SAVE_XMM_REGS - Save xmm argument registers to the stack,
248d6708eade079c30b0790789a00a8d737d84f52b7Dan Gohman      // according to %al. An operator is needed so that this can be expanded
249d6708eade079c30b0790789a00a8d737d84f52b7Dan Gohman      // with control flow.
250c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohman      VASTART_SAVE_XMM_REGS,
251c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohman
252043f3c2a0e286dcfd4cc5a16bf006e3c45929516Anton Korobeynikov      // MINGW_ALLOCA - MingW's __alloca call to do stack probing.
253043f3c2a0e286dcfd4cc5a16bf006e3c45929516Anton Korobeynikov      MINGW_ALLOCA,
254043f3c2a0e286dcfd4cc5a16bf006e3c45929516Anton Korobeynikov
255c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohman      // ATOMADD64_DAG, ATOMSUB64_DAG, ATOMOR64_DAG, ATOMAND64_DAG,
256c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohman      // ATOMXOR64_DAG, ATOMNAND64_DAG, ATOMSWAP64_DAG -
257c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohman      // Atomic 64-bit binary operations.
258c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohman      ATOMADD64_DAG = ISD::FIRST_TARGET_MEMORY_OPCODE,
259c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohman      ATOMSUB64_DAG,
260c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohman      ATOMOR64_DAG,
261c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohman      ATOMXOR64_DAG,
262c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohman      ATOMAND64_DAG,
263c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohman      ATOMNAND64_DAG,
264c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohman      ATOMSWAP64_DAG
265043f3c2a0e286dcfd4cc5a16bf006e3c45929516Anton Korobeynikov
266043f3c2a0e286dcfd4cc5a16bf006e3c45929516Anton Korobeynikov      // WARNING: Do not add anything in the end unless you want the node to
267043f3c2a0e286dcfd4cc5a16bf006e3c45929516Anton Korobeynikov      // have memop! In fact, starting from ATOMADD64_DAG all opcodes will be
268043f3c2a0e286dcfd4cc5a16bf006e3c45929516Anton Korobeynikov      // thought as target memory ops!
269dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner    };
270dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner  }
271dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner
2720d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng  /// Define some predicates that are used for node matching.
2730d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng  namespace X86 {
2740d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// isPSHUFDMask - Return true if the specified VECTOR_SHUFFLE operand
2750d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// specifies a shuffle of elements that is suitable for input to PSHUFD.
2769008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman    bool isPSHUFDMask(ShuffleVectorSDNode *N);
2770d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng
2780d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// isPSHUFHWMask - Return true if the specified VECTOR_SHUFFLE operand
2790d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// specifies a shuffle of elements that is suitable for input to PSHUFD.
2809008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman    bool isPSHUFHWMask(ShuffleVectorSDNode *N);
2810d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng
2820d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// isPSHUFLWMask - Return true if the specified VECTOR_SHUFFLE operand
2830d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// specifies a shuffle of elements that is suitable for input to PSHUFD.
2849008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman    bool isPSHUFLWMask(ShuffleVectorSDNode *N);
2850d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng
2860d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// isSHUFPMask - Return true if the specified VECTOR_SHUFFLE operand
2870d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// specifies a shuffle of elements that is suitable for input to SHUFP*.
2889008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman    bool isSHUFPMask(ShuffleVectorSDNode *N);
2890d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng
2900d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// isMOVHLPSMask - Return true if the specified VECTOR_SHUFFLE operand
2910d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// specifies a shuffle of elements that is suitable for input to MOVHLPS.
2929008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman    bool isMOVHLPSMask(ShuffleVectorSDNode *N);
2930d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng
2940d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// isMOVHLPS_v_undef_Mask - Special case of isMOVHLPSMask for canonical form
2950d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// of vector_shuffle v, v, <2, 3, 2, 3>, i.e. vector_shuffle v, undef,
2960d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// <2, 3, 2, 3>
2979008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman    bool isMOVHLPS_v_undef_Mask(ShuffleVectorSDNode *N);
2980d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng
2990d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// isMOVLPMask - Return true if the specified VECTOR_SHUFFLE operand
3009008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman    /// specifies a shuffle of elements that is suitable for MOVLP{S|D}.
3019008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman    bool isMOVLPMask(ShuffleVectorSDNode *N);
3020d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng
3030d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// isMOVHPMask - Return true if the specified VECTOR_SHUFFLE operand
3049008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman    /// specifies a shuffle of elements that is suitable for MOVHP{S|D}.
3050d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// as well as MOVLHPS.
3060b10b91465e69c4ae3649115486e1eb56b8be878Nate Begeman    bool isMOVLHPSMask(ShuffleVectorSDNode *N);
3070d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng
3080d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// isUNPCKLMask - Return true if the specified VECTOR_SHUFFLE operand
3090d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// specifies a shuffle of elements that is suitable for input to UNPCKL.
3109008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman    bool isUNPCKLMask(ShuffleVectorSDNode *N, bool V2IsSplat = false);
3110d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng
3120d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// isUNPCKHMask - Return true if the specified VECTOR_SHUFFLE operand
3130d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// specifies a shuffle of elements that is suitable for input to UNPCKH.
3149008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman    bool isUNPCKHMask(ShuffleVectorSDNode *N, bool V2IsSplat = false);
3150d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng
3160d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// isUNPCKL_v_undef_Mask - Special case of isUNPCKLMask for canonical form
3170d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// of vector_shuffle v, v, <0, 4, 1, 5>, i.e. vector_shuffle v, undef,
3180d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// <0, 0, 1, 1>
3199008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman    bool isUNPCKL_v_undef_Mask(ShuffleVectorSDNode *N);
3200d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng
3210d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// isUNPCKH_v_undef_Mask - Special case of isUNPCKHMask for canonical form
3220d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// of vector_shuffle v, v, <2, 6, 3, 7>, i.e. vector_shuffle v, undef,
3230d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// <2, 2, 3, 3>
3249008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman    bool isUNPCKH_v_undef_Mask(ShuffleVectorSDNode *N);
3250d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng
3260d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// isMOVLMask - Return true if the specified VECTOR_SHUFFLE operand
3270d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// specifies a shuffle of elements that is suitable for input to MOVSS,
3280d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// MOVSD, and MOVD, i.e. setting the lowest element.
3299008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman    bool isMOVLMask(ShuffleVectorSDNode *N);
3300d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng
3310d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// isMOVSHDUPMask - Return true if the specified VECTOR_SHUFFLE operand
3320d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// specifies a shuffle of elements that is suitable for input to MOVSHDUP.
3339008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman    bool isMOVSHDUPMask(ShuffleVectorSDNode *N);
3340d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng
3350d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// isMOVSLDUPMask - Return true if the specified VECTOR_SHUFFLE operand
3360d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// specifies a shuffle of elements that is suitable for input to MOVSLDUP.
3379008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman    bool isMOVSLDUPMask(ShuffleVectorSDNode *N);
3380d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng
3390b457f0c3a7e21b1fb9ac8b9f8e404e1312b6a60Evan Cheng    /// isMOVDDUPMask - Return true if the specified VECTOR_SHUFFLE operand
3400b457f0c3a7e21b1fb9ac8b9f8e404e1312b6a60Evan Cheng    /// specifies a shuffle of elements that is suitable for input to MOVDDUP.
3419008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman    bool isMOVDDUPMask(ShuffleVectorSDNode *N);
3420b457f0c3a7e21b1fb9ac8b9f8e404e1312b6a60Evan Cheng
343a09008bf6ddb61910212c31db1d714182882681eNate Begeman    /// isPALIGNRMask - Return true if the specified VECTOR_SHUFFLE operand
344a09008bf6ddb61910212c31db1d714182882681eNate Begeman    /// specifies a shuffle of elements that is suitable for input to PALIGNR.
345a09008bf6ddb61910212c31db1d714182882681eNate Begeman    bool isPALIGNRMask(ShuffleVectorSDNode *N);
346a09008bf6ddb61910212c31db1d714182882681eNate Begeman
3470d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// getShuffleSHUFImmediate - Return the appropriate immediate to shuffle
3480d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// the specified isShuffleMask VECTOR_SHUFFLE mask with PSHUF* and SHUFP*
3490d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// instructions.
3500d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    unsigned getShuffleSHUFImmediate(SDNode *N);
3510d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng
3520d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    /// getShufflePSHUFHWImmediate - Return the appropriate immediate to shuffle
353a09008bf6ddb61910212c31db1d714182882681eNate Begeman    /// the specified VECTOR_SHUFFLE mask with PSHUFHW instruction.
3540d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    unsigned getShufflePSHUFHWImmediate(SDNode *N);
3550d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng
356a09008bf6ddb61910212c31db1d714182882681eNate Begeman    /// getShufflePSHUFLWImmediate - Return the appropriate immediate to shuffle
357a09008bf6ddb61910212c31db1d714182882681eNate Begeman    /// the specified VECTOR_SHUFFLE mask with PSHUFLW instruction.
3580d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng    unsigned getShufflePSHUFLWImmediate(SDNode *N);
35937b7387da90ffd42d28ad0f08fca00b684294b2cEvan Cheng
360a09008bf6ddb61910212c31db1d714182882681eNate Begeman    /// getShufflePALIGNRImmediate - Return the appropriate immediate to shuffle
361a09008bf6ddb61910212c31db1d714182882681eNate Begeman    /// the specified VECTOR_SHUFFLE mask with the PALIGNR instruction.
362a09008bf6ddb61910212c31db1d714182882681eNate Begeman    unsigned getShufflePALIGNRImmediate(SDNode *N);
363a09008bf6ddb61910212c31db1d714182882681eNate Begeman
36437b7387da90ffd42d28ad0f08fca00b684294b2cEvan Cheng    /// isZeroNode - Returns true if Elt is a constant zero or a floating point
36537b7387da90ffd42d28ad0f08fca00b684294b2cEvan Cheng    /// constant +0.0.
36637b7387da90ffd42d28ad0f08fca00b684294b2cEvan Cheng    bool isZeroNode(SDValue Elt);
367b5e01724057e6eabc45da75df3037af4ad29248cAnton Korobeynikov
368b5e01724057e6eabc45da75df3037af4ad29248cAnton Korobeynikov    /// isOffsetSuitableForCodeModel - Returns true of the given offset can be
369b5e01724057e6eabc45da75df3037af4ad29248cAnton Korobeynikov    /// fit into displacement field of the instruction.
370b5e01724057e6eabc45da75df3037af4ad29248cAnton Korobeynikov    bool isOffsetSuitableForCodeModel(int64_t Offset, CodeModel::Model M,
371b5e01724057e6eabc45da75df3037af4ad29248cAnton Korobeynikov                                      bool hasSymbolicDisplacement = true);
3720d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng  }
3730d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng
37491897778690a7d683497ba3f4040ebf09345f08aChris Lattner  //===--------------------------------------------------------------------===//
375dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner  //  X86TargetLowering - X86 Implementation of the TargetLowering interface
376dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner  class X86TargetLowering : public TargetLowering {
377dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner    int VarArgsFrameIndex;            // FrameIndex for start of varargs area.
37825ab690a43cbbb591b76d49e3595b019c32f4b3fEvan Cheng    int RegSaveFrameIndex;            // X86-64 vararg func register save area.
37925ab690a43cbbb591b76d49e3595b019c32f4b3fEvan Cheng    unsigned VarArgsGPOffset;         // X86-64 vararg func int reg offset.
38025ab690a43cbbb591b76d49e3595b019c32f4b3fEvan Cheng    unsigned VarArgsFPOffset;         // X86-64 vararg func fp reg offset.
381dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner    int BytesToPopOnReturn;           // Number of arg bytes ret should pop.
382c85e1716f0e45e4c18a9ef2fbe431a51ac3a4252Arnold Schwaighofer
383dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner  public:
384c9f5f3f64f896d0a8c8fa35a1dd98bc57b8960f6Dan Gohman    explicit X86TargetLowering(X86TargetMachine &TM);
385dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner
386589c6f620e8dcf3d59af1ae0e15372c934647c82Chris Lattner    /// getPICBaseSymbol - Return the X86-32 PIC base.
387589c6f620e8dcf3d59af1ae0e15372c934647c82Chris Lattner    MCSymbol *getPICBaseSymbol(const MachineFunction *MF, MCContext &Ctx) const;
388589c6f620e8dcf3d59af1ae0e15372c934647c82Chris Lattner
389c64daabb70a2e0cb115f78b0c1548e65c0d527ffChris Lattner    virtual unsigned getJumpTableEncoding() const;
3905e1df8d1f71f1a8a534b8b5929a7dd670fe010c6Chris Lattner
391c64daabb70a2e0cb115f78b0c1548e65c0d527ffChris Lattner    virtual const MCExpr *
392c64daabb70a2e0cb115f78b0c1548e65c0d527ffChris Lattner    LowerCustomJumpTableEntry(const MachineJumpTableInfo *MJTI,
393c64daabb70a2e0cb115f78b0c1548e65c0d527ffChris Lattner                              const MachineBasicBlock *MBB, unsigned uid,
394c64daabb70a2e0cb115f78b0c1548e65c0d527ffChris Lattner                              MCContext &Ctx) const;
395c64daabb70a2e0cb115f78b0c1548e65c0d527ffChris Lattner
396cc41586b9d79532172b37e1f44a9077da4b73fc9Evan Cheng    /// getPICJumpTableRelocaBase - Returns relocation base for the given PIC
397cc41586b9d79532172b37e1f44a9077da4b73fc9Evan Cheng    /// jumptable.
398c64daabb70a2e0cb115f78b0c1548e65c0d527ffChris Lattner    virtual SDValue getPICJumpTableRelocBase(SDValue Table,
399c64daabb70a2e0cb115f78b0c1548e65c0d527ffChris Lattner                                             SelectionDAG &DAG) const;
400589c6f620e8dcf3d59af1ae0e15372c934647c82Chris Lattner    virtual const MCExpr *
401589c6f620e8dcf3d59af1ae0e15372c934647c82Chris Lattner    getPICJumpTableRelocBaseExpr(const MachineFunction *MF,
402589c6f620e8dcf3d59af1ae0e15372c934647c82Chris Lattner                                 unsigned JTI, MCContext &Ctx) const;
403589c6f620e8dcf3d59af1ae0e15372c934647c82Chris Lattner
404dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner    // Return the number of bytes that a function should pop when it returns (in
405dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner    // addition to the space used by the return address).
406dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner    //
407dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner    unsigned getBytesToPopOnReturn() const { return BytesToPopOnReturn; }
408dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner
40954e3efde4636dade74f95ede039091bf52ca1585Chris Lattner    /// getStackPtrReg - Return the stack pointer register we are using: either
41054e3efde4636dade74f95ede039091bf52ca1585Chris Lattner    /// ESP or RSP.
41154e3efde4636dade74f95ede039091bf52ca1585Chris Lattner    unsigned getStackPtrReg() const { return X86StackPtr; }
41229286502628867b31872ead2f2527592480f0970Evan Cheng
41329286502628867b31872ead2f2527592480f0970Evan Cheng    /// getByValTypeAlignment - Return the desired alignment for ByVal aggregate
41429286502628867b31872ead2f2527592480f0970Evan Cheng    /// function arguments in the caller parameter area. For X86, aggregates
41529286502628867b31872ead2f2527592480f0970Evan Cheng    /// that contains are placed at 16-byte boundaries while the rest are at
41629286502628867b31872ead2f2527592480f0970Evan Cheng    /// 4-byte boundaries.
41729286502628867b31872ead2f2527592480f0970Evan Cheng    virtual unsigned getByValTypeAlignment(const Type *Ty) const;
418f0df03134e698ea84e9cc1c28a853f83c02560d5Evan Cheng
419f0df03134e698ea84e9cc1c28a853f83c02560d5Evan Cheng    /// getOptimalMemOpType - Returns the target specific optimal type for load
4200ef8de30fa8dd317c8b45711fe144d39e51ecfa4Evan Cheng    /// and store operations as a result of memset, memcpy, and memmove
421e50ed30282bb5b4a9ed952580523f2dda16215acOwen Anderson    /// lowering. It returns EVT::iAny if SelectionDAG should be responsible for
422f0df03134e698ea84e9cc1c28a853f83c02560d5Evan Cheng    /// determining it.
423af5663405834ca7cf4a847f2efa2d624ce99b1d8Bill Wendling    virtual EVT getOptimalMemOpType(uint64_t Size, unsigned Align,
424af5663405834ca7cf4a847f2efa2d624ce99b1d8Bill Wendling                                    bool isSrcConst, bool isSrcStr,
425af5663405834ca7cf4a847f2efa2d624ce99b1d8Bill Wendling                                    SelectionDAG &DAG) const;
426af5663405834ca7cf4a847f2efa2d624ce99b1d8Bill Wendling
427af5663405834ca7cf4a847f2efa2d624ce99b1d8Bill Wendling    /// allowsUnalignedMemoryAccesses - Returns true if the target allows
428af5663405834ca7cf4a847f2efa2d624ce99b1d8Bill Wendling    /// unaligned memory accesses. of the specified type.
429af5663405834ca7cf4a847f2efa2d624ce99b1d8Bill Wendling    virtual bool allowsUnalignedMemoryAccesses(EVT VT) const {
430af5663405834ca7cf4a847f2efa2d624ce99b1d8Bill Wendling      return true;
431af5663405834ca7cf4a847f2efa2d624ce99b1d8Bill Wendling    }
43220c568f366be211323eeaf0e45ef053278ec9ddcBill Wendling
433dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner    /// LowerOperation - Provide custom lowering hooks for some operations.
434dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner    ///
435475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG);
436dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner
4371607f05cb7d77d01ce521a30232faa389dbed4e2Duncan Sands    /// ReplaceNodeResults - Replace the results of node with an illegal result
4381607f05cb7d77d01ce521a30232faa389dbed4e2Duncan Sands    /// type with new values built out of custom code.
43927a6c7380fa4dfc8e1837a8dd67967d063b26544Chris Lattner    ///
4401607f05cb7d77d01ce521a30232faa389dbed4e2Duncan Sands    virtual void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results,
4411607f05cb7d77d01ce521a30232faa389dbed4e2Duncan Sands                                    SelectionDAG &DAG);
44227a6c7380fa4dfc8e1837a8dd67967d063b26544Chris Lattner
44327a6c7380fa4dfc8e1837a8dd67967d063b26544Chris Lattner
444475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    virtual SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const;
445206ee9d86cd4e78176fad6bfa2b016023edf5df7Evan Cheng
446ff9b373e8f5006c629af81e2619778b4c4f5249eEvan Cheng    virtual MachineBasicBlock *EmitInstrWithCustomInserter(MachineInstr *MI,
447fb2e752e4175920d0531f2afc93a23d0cdf4db14Evan Cheng                                                         MachineBasicBlock *MBB,
448fb2e752e4175920d0531f2afc93a23d0cdf4db14Evan Cheng                    DenseMap<MachineBasicBlock*, MachineBasicBlock*> *EM) const;
4494a46080fe0133c71b511805c63abfb158dcd56a5Evan Cheng
45063307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang
4517226158d7e3986e55b58214a749aa4eabb3fb6d5Evan Cheng    /// getTargetNodeName - This method returns the name of a target specific
4527226158d7e3986e55b58214a749aa4eabb3fb6d5Evan Cheng    /// DAG node.
4537226158d7e3986e55b58214a749aa4eabb3fb6d5Evan Cheng    virtual const char *getTargetNodeName(unsigned Opcode) const;
4547226158d7e3986e55b58214a749aa4eabb3fb6d5Evan Cheng
4555b8f82e35b51bf007de07a7ca9347d804084ddf8Scott Michel    /// getSetCCResultType - Return the ISD::SETCC ValueType
456825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson    virtual MVT::SimpleValueType getSetCCResultType(EVT VT) const;
4575b8f82e35b51bf007de07a7ca9347d804084ddf8Scott Michel
458368e18d56a87308045d341e85584597bfe7426e9Nate Begeman    /// computeMaskedBitsForTargetNode - Determine which of the bits specified
459368e18d56a87308045d341e85584597bfe7426e9Nate Begeman    /// in Mask are known to be either zero or one and return them in the
460368e18d56a87308045d341e85584597bfe7426e9Nate Begeman    /// KnownZero/KnownOne bitsets.
461475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    virtual void computeMaskedBitsForTargetNode(const SDValue Op,
462977a76fbb6ea1b87dfd7fbbe2ae2afb63e982ff3Dan Gohman                                                const APInt &Mask,
463fd29e0eb060ea8b4d490860329234d2ae5f5952eDan Gohman                                                APInt &KnownZero,
464fd29e0eb060ea8b4d490860329234d2ae5f5952eDan Gohman                                                APInt &KnownOne,
465ea859be53ca13a1547c4675549946b74dc3c6f41Dan Gohman                                                const SelectionDAG &DAG,
466368e18d56a87308045d341e85584597bfe7426e9Nate Begeman                                                unsigned Depth = 0) const;
467ad4196b44ae714a6b95e238d9d96303df74b0429Evan Cheng
468ad4196b44ae714a6b95e238d9d96303df74b0429Evan Cheng    virtual bool
469ad4196b44ae714a6b95e238d9d96303df74b0429Evan Cheng    isGAPlusOffset(SDNode *N, GlobalValue* &GA, int64_t &Offset) const;
470368e18d56a87308045d341e85584597bfe7426e9Nate Begeman
471475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue getReturnAddressFrameIndex(SelectionDAG &DAG);
472dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner
473b8105651527670cb456eb46dd4346bacd3905361Chris Lattner    virtual bool ExpandInlineAsm(CallInst *CI) const;
474b8105651527670cb456eb46dd4346bacd3905361Chris Lattner
4754234f57fa02b1f04a9f52a7b3c2aa22d32ac521cChris Lattner    ConstraintType getConstraintType(const std::string &Constraint) const;
476f4dff84c8614fc2106d821e4687c933d8d4b9420Chris Lattner
477259e97cc725011a3c138563d421a4654b082a64cChris Lattner    std::vector<unsigned>
4781efa40f6a4b561cf8f80fe018684236010645cd0Chris Lattner      getRegClassForInlineAsmConstraint(const std::string &Constraint,
479e50ed30282bb5b4a9ed952580523f2dda16215acOwen Anderson                                        EVT VT) const;
48048884cd80b52be1528618f2e9b3425ac24e7b5caChris Lattner
481e50ed30282bb5b4a9ed952580523f2dda16215acOwen Anderson    virtual const char *LowerXConstraint(EVT ConstraintVT) const;
482ba2a0b960ea4c73d0f81557f63ae2ea126e08905Dale Johannesen
48348884cd80b52be1528618f2e9b3425ac24e7b5caChris Lattner    /// LowerAsmOperandForConstraint - Lower the specified operand into the Ops
484da43bcf624acb56a3d77bb5ae9a02728af032613Evan Cheng    /// vector.  If it is invalid, don't add anything to Ops. If hasMemory is
485da43bcf624acb56a3d77bb5ae9a02728af032613Evan Cheng    /// true it means one of the asm constraint of the inline asm instruction
486da43bcf624acb56a3d77bb5ae9a02728af032613Evan Cheng    /// being processed is 'm'.
487475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    virtual void LowerAsmOperandForConstraint(SDValue Op,
48848884cd80b52be1528618f2e9b3425ac24e7b5caChris Lattner                                              char ConstraintLetter,
489da43bcf624acb56a3d77bb5ae9a02728af032613Evan Cheng                                              bool hasMemory,
490475871a144eb604ddaf37503397ba0941442e5fbDan Gohman                                              std::vector<SDValue> &Ops,
4915e764233f398b6929b67701672a5e78fec20ce2eChris Lattner                                              SelectionDAG &DAG) const;
49222aaf1d61c6a752d66f7ee10a7a5d99c7160e007Chris Lattner
49391897778690a7d683497ba3f4040ebf09345f08aChris Lattner    /// getRegForInlineAsmConstraint - Given a physical register constraint
49491897778690a7d683497ba3f4040ebf09345f08aChris Lattner    /// (e.g. {edx}), return the register number and the register class for the
49591897778690a7d683497ba3f4040ebf09345f08aChris Lattner    /// register.  This should only be used for C_Register constraints.  On
49691897778690a7d683497ba3f4040ebf09345f08aChris Lattner    /// error, this returns a register number of 0.
497f76d180c9595d34641f4b5d2fbba2f2c175197d8Chris Lattner    std::pair<unsigned, const TargetRegisterClass*>
498f76d180c9595d34641f4b5d2fbba2f2c175197d8Chris Lattner      getRegForInlineAsmConstraint(const std::string &Constraint,
499e50ed30282bb5b4a9ed952580523f2dda16215acOwen Anderson                                   EVT VT) const;
500f76d180c9595d34641f4b5d2fbba2f2c175197d8Chris Lattner
501c9addb74883fef318140272768422656a694341fChris Lattner    /// isLegalAddressingMode - Return true if the addressing mode represented
502c9addb74883fef318140272768422656a694341fChris Lattner    /// by AM is legal for this target, for a load/store of the specified type.
503c9addb74883fef318140272768422656a694341fChris Lattner    virtual bool isLegalAddressingMode(const AddrMode &AM, const Type *Ty)const;
504c9addb74883fef318140272768422656a694341fChris Lattner
5052bd122c4d934a70e031dc0ca5171719bac66c2c9Evan Cheng    /// isTruncateFree - Return true if it's free to truncate a value of
5062bd122c4d934a70e031dc0ca5171719bac66c2c9Evan Cheng    /// type Ty1 to type Ty2. e.g. On x86 it's free to truncate a i32 value in
5072bd122c4d934a70e031dc0ca5171719bac66c2c9Evan Cheng    /// register EAX to i16 by referencing its sub-register AX.
5082bd122c4d934a70e031dc0ca5171719bac66c2c9Evan Cheng    virtual bool isTruncateFree(const Type *Ty1, const Type *Ty2) const;
509e50ed30282bb5b4a9ed952580523f2dda16215acOwen Anderson    virtual bool isTruncateFree(EVT VT1, EVT VT2) const;
51097121ba2afb8d566ff1bf5c4e8fc5d4077940a7fDan Gohman
51197121ba2afb8d566ff1bf5c4e8fc5d4077940a7fDan Gohman    /// isZExtFree - Return true if any actual instruction that defines a
51297121ba2afb8d566ff1bf5c4e8fc5d4077940a7fDan Gohman    /// value of type Ty1 implicit zero-extends the value to Ty2 in the result
51397121ba2afb8d566ff1bf5c4e8fc5d4077940a7fDan Gohman    /// register. This does not necessarily include registers defined in
51497121ba2afb8d566ff1bf5c4e8fc5d4077940a7fDan Gohman    /// unknown ways, such as incoming arguments, or copies from unknown
51597121ba2afb8d566ff1bf5c4e8fc5d4077940a7fDan Gohman    /// virtual registers. Also, if isTruncateFree(Ty2, Ty1) is true, this
51697121ba2afb8d566ff1bf5c4e8fc5d4077940a7fDan Gohman    /// does not necessarily apply to truncate instructions. e.g. on x86-64,
51797121ba2afb8d566ff1bf5c4e8fc5d4077940a7fDan Gohman    /// all instructions that define 32-bit values implicit zero-extend the
51897121ba2afb8d566ff1bf5c4e8fc5d4077940a7fDan Gohman    /// result out to 64 bits.
51997121ba2afb8d566ff1bf5c4e8fc5d4077940a7fDan Gohman    virtual bool isZExtFree(const Type *Ty1, const Type *Ty2) const;
520e50ed30282bb5b4a9ed952580523f2dda16215acOwen Anderson    virtual bool isZExtFree(EVT VT1, EVT VT2) const;
52197121ba2afb8d566ff1bf5c4e8fc5d4077940a7fDan Gohman
5228b944d39b356135676459152385f05c496951f6cEvan Cheng    /// isNarrowingProfitable - Return true if it's profitable to narrow
5238b944d39b356135676459152385f05c496951f6cEvan Cheng    /// operations of type VT1 to VT2. e.g. on x86, it's profitable to narrow
5248b944d39b356135676459152385f05c496951f6cEvan Cheng    /// from i32 to i8 but not from i32 to i16.
525e50ed30282bb5b4a9ed952580523f2dda16215acOwen Anderson    virtual bool isNarrowingProfitable(EVT VT1, EVT VT2) const;
5268b944d39b356135676459152385f05c496951f6cEvan Cheng
527eb2f969a4ddfb0bc8fdcb5bce3b52e53abff321dEvan Cheng    /// isFPImmLegal - Returns true if the target can instruction select the
528eb2f969a4ddfb0bc8fdcb5bce3b52e53abff321dEvan Cheng    /// specified FP immediate natively. If false, the legalizer will
529eb2f969a4ddfb0bc8fdcb5bce3b52e53abff321dEvan Cheng    /// materialize the FP immediate as a load from a constant pool.
530a1eaa3c52b75d4fe2bcd4f7c52e56c405ee91d3cEvan Cheng    virtual bool isFPImmLegal(const APFloat &Imm, EVT VT) const;
531eb2f969a4ddfb0bc8fdcb5bce3b52e53abff321dEvan Cheng
5320188ecba85c7139f237baa4ce5612fdfc83e1b84Evan Cheng    /// isShuffleMaskLegal - Targets can use this to indicate that they only
5330188ecba85c7139f237baa4ce5612fdfc83e1b84Evan Cheng    /// support *some* VECTOR_SHUFFLE operations, those with specific masks.
53491897778690a7d683497ba3f4040ebf09345f08aChris Lattner    /// By default, if a target supports the VECTOR_SHUFFLE node, all mask
53591897778690a7d683497ba3f4040ebf09345f08aChris Lattner    /// values are assumed to be legal.
5365a5ca1519e04310f585197c20e7ae584b7f2d11fNate Begeman    virtual bool isShuffleMaskLegal(const SmallVectorImpl<int> &Mask,
537e50ed30282bb5b4a9ed952580523f2dda16215acOwen Anderson                                    EVT VT) const;
53839623daef67090025be5cd8af7d172fd1c9e6418Evan Cheng
53939623daef67090025be5cd8af7d172fd1c9e6418Evan Cheng    /// isVectorClearMaskLegal - Similar to isShuffleMaskLegal. This is
54039623daef67090025be5cd8af7d172fd1c9e6418Evan Cheng    /// used by Targets can use this to indicate if there is a suitable
54139623daef67090025be5cd8af7d172fd1c9e6418Evan Cheng    /// VECTOR_SHUFFLE that can be used to replace a VAND with a constant
54239623daef67090025be5cd8af7d172fd1c9e6418Evan Cheng    /// pool entry.
5435a5ca1519e04310f585197c20e7ae584b7f2d11fNate Begeman    virtual bool isVectorClearMaskLegal(const SmallVectorImpl<int> &Mask,
544e50ed30282bb5b4a9ed952580523f2dda16215acOwen Anderson                                        EVT VT) const;
5456fd599fa6916bd9438dbea7994cf2437bdf4ab8cEvan Cheng
5466fd599fa6916bd9438dbea7994cf2437bdf4ab8cEvan Cheng    /// ShouldShrinkFPConstant - If true, then instruction selection should
5476fd599fa6916bd9438dbea7994cf2437bdf4ab8cEvan Cheng    /// seek to shrink the FP constant of the specified type to a smaller type
5486fd599fa6916bd9438dbea7994cf2437bdf4ab8cEvan Cheng    /// in order to save space and / or reduce runtime.
549e50ed30282bb5b4a9ed952580523f2dda16215acOwen Anderson    virtual bool ShouldShrinkFPConstant(EVT VT) const {
5506fd599fa6916bd9438dbea7994cf2437bdf4ab8cEvan Cheng      // Don't shrink FP constpool if SSE2 is available since cvtss2sd is more
5516fd599fa6916bd9438dbea7994cf2437bdf4ab8cEvan Cheng      // expensive than a straight movsd. On the other hand, it's important to
5526fd599fa6916bd9438dbea7994cf2437bdf4ab8cEvan Cheng      // shrink long double fp constant since fldt is very slow.
553825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson      return !X86ScalarSSEf64 || VT == MVT::f80;
5546fd599fa6916bd9438dbea7994cf2437bdf4ab8cEvan Cheng    }
555c85e1716f0e45e4c18a9ef2fbe431a51ac3a4252Arnold Schwaighofer
556707e0184233f27e0e9f9aee0309f2daab8cfe7f8Dan Gohman    virtual const X86Subtarget* getSubtarget() {
557707e0184233f27e0e9f9aee0309f2daab8cfe7f8Dan Gohman      return Subtarget;
558f1ba1cad387dc52f3c2c5afc665edf9caad00992Rafael Espindola    }
559f1ba1cad387dc52f3c2c5afc665edf9caad00992Rafael Espindola
5603d66185ff8b276183fa8e9ce3d7ebb1d9ce88f74Chris Lattner    /// isScalarFPTypeInSSEReg - Return true if the specified scalar FP type is
5613d66185ff8b276183fa8e9ce3d7ebb1d9ce88f74Chris Lattner    /// computed in an SSE register, not on the X87 floating point stack.
562e50ed30282bb5b4a9ed952580523f2dda16215acOwen Anderson    bool isScalarFPTypeInSSEReg(EVT VT) const {
563825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson      return (VT == MVT::f64 && X86ScalarSSEf64) || // f64 is when SSE2
564825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson      (VT == MVT::f32 && X86ScalarSSEf32);   // f32 is when SSE1
5653d66185ff8b276183fa8e9ce3d7ebb1d9ce88f74Chris Lattner    }
566d9f3c480a7bc0969b08ace68af7dcde40f6caff1Dan Gohman
567d9f3c480a7bc0969b08ace68af7dcde40f6caff1Dan Gohman    /// createFastISel - This method returns a target specific FastISel object,
568d9f3c480a7bc0969b08ace68af7dcde40f6caff1Dan Gohman    /// or null if the target does not support "fast" ISel.
5693df24e667f04a7003342b534310919abc9c87418Dan Gohman    virtual FastISel *
5703df24e667f04a7003342b534310919abc9c87418Dan Gohman    createFastISel(MachineFunction &mf,
57183489bb7700c69b7a4a8da59365c42d3f5c8129bDevang Patel                   MachineModuleInfo *mmi, DwarfWriter *dw,
5723df24e667f04a7003342b534310919abc9c87418Dan Gohman                   DenseMap<const Value *, unsigned> &,
5730586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman                   DenseMap<const BasicBlock *, MachineBasicBlock *> &,
574dd5b58ad7be78be90390074f0df138778af5c895Dan Gohman                   DenseMap<const AllocaInst *, int> &
575dd5b58ad7be78be90390074f0df138778af5c895Dan Gohman#ifndef NDEBUG
576dd5b58ad7be78be90390074f0df138778af5c895Dan Gohman                   , SmallSet<Instruction*, 8> &
577dd5b58ad7be78be90390074f0df138778af5c895Dan Gohman#endif
578dd5b58ad7be78be90390074f0df138778af5c895Dan Gohman                   );
57920c568f366be211323eeaf0e45ef053278ec9ddcBill Wendling
580b4202b84d7e54efe5e144885c7da63e6cc465f80Bill Wendling    /// getFunctionAlignment - Return the Log2 alignment of this function.
58120c568f366be211323eeaf0e45ef053278ec9ddcBill Wendling    virtual unsigned getFunctionAlignment(const Function *F) const;
58220c568f366be211323eeaf0e45ef053278ec9ddcBill Wendling
583dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner  private:
5840db9fe6775853d62632ad299dd734b6ba6c6b336Evan Cheng    /// Subtarget - Keep a pointer to the X86Subtarget around so that we can
5850db9fe6775853d62632ad299dd734b6ba6c6b336Evan Cheng    /// make the right decision when generating code for different targets.
5860db9fe6775853d62632ad299dd734b6ba6c6b336Evan Cheng    const X86Subtarget *Subtarget;
587c9f5f3f64f896d0a8c8fa35a1dd98bc57b8960f6Dan Gohman    const X86RegisterInfo *RegInfo;
588bff66b0c6c8266a6f9ba6c9bd5d2541a4d4c6ec9Anton Korobeynikov    const TargetData *TD;
5890db9fe6775853d62632ad299dd734b6ba6c6b336Evan Cheng
59025ab690a43cbbb591b76d49e3595b019c32f4b3fEvan Cheng    /// X86StackPtr - X86 physical register used as stack ptr.
59125ab690a43cbbb591b76d49e3595b019c32f4b3fEvan Cheng    unsigned X86StackPtr;
592c85e1716f0e45e4c18a9ef2fbe431a51ac3a4252Arnold Schwaighofer
593f1fc3a8fa6d4e81e30c08983d786c640acb2591cDale Johannesen    /// X86ScalarSSEf32, X86ScalarSSEf64 - Select between SSE or x87
594f1fc3a8fa6d4e81e30c08983d786c640acb2591cDale Johannesen    /// floating point ops.
595f1fc3a8fa6d4e81e30c08983d786c640acb2591cDale Johannesen    /// When SSE is available, use it for f32 operations.
596f1fc3a8fa6d4e81e30c08983d786c640acb2591cDale Johannesen    /// When SSE2 is available, use it for f64 operations.
597f1fc3a8fa6d4e81e30c08983d786c640acb2591cDale Johannesen    bool X86ScalarSSEf32;
598f1fc3a8fa6d4e81e30c08983d786c640acb2591cDale Johannesen    bool X86ScalarSSEf64;
5990d9e976ad2c5479f3d67f8cb09a5908cfc29985cEvan Cheng
600eb2f969a4ddfb0bc8fdcb5bce3b52e53abff321dEvan Cheng    /// LegalFPImmediates - A list of legal fp immediates.
601eb2f969a4ddfb0bc8fdcb5bce3b52e53abff321dEvan Cheng    std::vector<APFloat> LegalFPImmediates;
602eb2f969a4ddfb0bc8fdcb5bce3b52e53abff321dEvan Cheng
603eb2f969a4ddfb0bc8fdcb5bce3b52e53abff321dEvan Cheng    /// addLegalFPImmediate - Indicate that this x86 target can instruction
604eb2f969a4ddfb0bc8fdcb5bce3b52e53abff321dEvan Cheng    /// select the specified FP immediate natively.
605eb2f969a4ddfb0bc8fdcb5bce3b52e53abff321dEvan Cheng    void addLegalFPImmediate(const APFloat& Imm) {
606eb2f969a4ddfb0bc8fdcb5bce3b52e53abff321dEvan Cheng      LegalFPImmediates.push_back(Imm);
607eb2f969a4ddfb0bc8fdcb5bce3b52e53abff321dEvan Cheng    }
608eb2f969a4ddfb0bc8fdcb5bce3b52e53abff321dEvan Cheng
60998ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman    SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
61065c3c8f323198b99b88b109654194540cf9b3fa5Sandeep Patel                            CallingConv::ID CallConv, bool isVarArg,
61198ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman                            const SmallVectorImpl<ISD::InputArg> &Ins,
61298ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman                            DebugLoc dl, SelectionDAG &DAG,
61398ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman                            SmallVectorImpl<SDValue> &InVals);
61498ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman    SDValue LowerMemArgument(SDValue Chain,
61565c3c8f323198b99b88b109654194540cf9b3fa5Sandeep Patel                             CallingConv::ID CallConv,
61698ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman                             const SmallVectorImpl<ISD::InputArg> &ArgInfo,
61798ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman                             DebugLoc dl, SelectionDAG &DAG,
61898ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman                             const CCValAssign &VA,  MachineFrameInfo *MFI,
61998ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman                              unsigned i);
62098ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman    SDValue LowerMemOpCallTo(SDValue Chain, SDValue StackPtr, SDValue Arg,
62198ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman                             DebugLoc dl, SelectionDAG &DAG,
62298ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman                             const CCValAssign &VA,
62398ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman                             ISD::ArgFlagsTy Flags);
6241b5dcc34b701639f94008658a2042abc43b9b910Rafael Espindola
62586737665b81550fdb575f7d8cc5decc801a7813dGordon Henriksen    // Call lowering helpers.
6260c439eb2c8397996cbccaf2798e598052d9982c8Evan Cheng
6270c439eb2c8397996cbccaf2798e598052d9982c8Evan Cheng    /// IsEligibleForTailCallOptimization - Check whether the call is eligible
6280c439eb2c8397996cbccaf2798e598052d9982c8Evan Cheng    /// for tail call optimization. Targets which want to do tail call
6290c439eb2c8397996cbccaf2798e598052d9982c8Evan Cheng    /// optimization should implement this function.
630022d9e1cef7586a80a96446ae8691a37def9bbf4Evan Cheng    bool IsEligibleForTailCallOptimization(SDValue Callee,
6310c439eb2c8397996cbccaf2798e598052d9982c8Evan Cheng                                           CallingConv::ID CalleeCC,
6320c439eb2c8397996cbccaf2798e598052d9982c8Evan Cheng                                           bool isVarArg,
633a375d471378b1674a9d77d180a0b05ea8c90cb4bEvan Cheng                                           bool isCalleeStructRet,
634a375d471378b1674a9d77d180a0b05ea8c90cb4bEvan Cheng                                           bool isCallerStructRet,
635b17124553d569c6f09347f2cbe072eab445d30c4Evan Cheng                                    const SmallVectorImpl<ISD::OutputArg> &Outs,
636b17124553d569c6f09347f2cbe072eab445d30c4Evan Cheng                                    const SmallVectorImpl<ISD::InputArg> &Ins,
6370c439eb2c8397996cbccaf2798e598052d9982c8Evan Cheng                                           SelectionDAG& DAG) const;
63865c3c8f323198b99b88b109654194540cf9b3fa5Sandeep Patel    bool IsCalleePop(bool isVarArg, CallingConv::ID CallConv);
639475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue EmitTailCallLoadRetAddr(SelectionDAG &DAG, SDValue &OutRetAddr,
640475871a144eb604ddaf37503397ba0941442e5fbDan Gohman                                SDValue Chain, bool IsTailCall, bool Is64Bit,
641ace1610df5fe22519d82cd7418a772e46ebd965bDale Johannesen                                int FPDiff, DebugLoc dl);
6424b5324ad2cbf774c9c6ed02ea0fcc864f2f5f885Arnold Schwaighofer
64365c3c8f323198b99b88b109654194540cf9b3fa5Sandeep Patel    CCAssignFn *CCAssignFnForNode(CallingConv::ID CallConv) const;
644c85e1716f0e45e4c18a9ef2fbe431a51ac3a4252Arnold Schwaighofer    unsigned GetAlignedArgumentStackSize(unsigned StackSize, SelectionDAG &DAG);
645559806f575297866609c7bef0e5c1084dcdda9a5Evan Cheng
646948e95a381bf6771639703643ef75e0115b35f53Eli Friedman    std::pair<SDValue,SDValue> FP_TO_INTHelper(SDValue Op, SelectionDAG &DAG,
647948e95a381bf6771639703643ef75e0115b35f53Eli Friedman                                               bool isSigned);
648c363094e04df621d41ca570eb2a7bf8826bb8c1aEvan Cheng
649c363094e04df621d41ca570eb2a7bf8826bb8c1aEvan Cheng    SDValue LowerAsSplatVectorLoad(SDValue SrcOp, EVT VT, DebugLoc dl,
650c363094e04df621d41ca570eb2a7bf8826bb8c1aEvan Cheng                                   SelectionDAG &DAG);
651475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG);
652eb38ebf15c326a5bb45ca9da6329cdf19ad6df95Mon P Wang    SDValue LowerCONCAT_VECTORS(SDValue Op, SelectionDAG &DAG);
653475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG);
654475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG);
655475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerEXTRACT_VECTOR_ELT_SSE4(SDValue Op, SelectionDAG &DAG);
656475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG);
657475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerINSERT_VECTOR_ELT_SSE4(SDValue Op, SelectionDAG &DAG);
658475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerSCALAR_TO_VECTOR(SDValue Op, SelectionDAG &DAG);
659475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG);
660f705adbe5ecd156de3f5a3017ddf4017e3890777Dan Gohman    SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG);
66133c960f523f2308482d5b2816af46a7ec90a6d3dDale Johannesen    SDValue LowerGlobalAddress(const GlobalValue *GV, DebugLoc dl,
66233c960f523f2308482d5b2816af46a7ec90a6d3dDale Johannesen                               int64_t Offset, SelectionDAG &DAG) const;
663475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG);
664475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG);
665475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerExternalSymbol(SDValue Op, SelectionDAG &DAG);
666475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerShift(SDValue Op, SelectionDAG &DAG);
667e50ed30282bb5b4a9ed952580523f2dda16215acOwen Anderson    SDValue BuildFILD(SDValue Op, EVT SrcVT, SDValue Chain, SDValue StackSlot,
668948e95a381bf6771639703643ef75e0115b35f53Eli Friedman                      SelectionDAG &DAG);
669475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerSINT_TO_FP(SDValue Op, SelectionDAG &DAG);
6701c15bf58a3700d40a6a88ac0ce14a2c99f111483Dale Johannesen    SDValue LowerUINT_TO_FP(SDValue Op, SelectionDAG &DAG);
6718b8a6368437abea4e4adb9afab455727f2da6624Bill Wendling    SDValue LowerUINT_TO_FP_i64(SDValue Op, SelectionDAG &DAG);
6728b8a6368437abea4e4adb9afab455727f2da6624Bill Wendling    SDValue LowerUINT_TO_FP_i32(SDValue Op, SelectionDAG &DAG);
673475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerFP_TO_SINT(SDValue Op, SelectionDAG &DAG);
674948e95a381bf6771639703643ef75e0115b35f53Eli Friedman    SDValue LowerFP_TO_UINT(SDValue Op, SelectionDAG &DAG);
675475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerFABS(SDValue Op, SelectionDAG &DAG);
676475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerFNEG(SDValue Op, SelectionDAG &DAG);
677475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerFCOPYSIGN(SDValue Op, SelectionDAG &DAG);
678475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG);
679475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerVSETCC(SDValue Op, SelectionDAG &DAG);
680475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG);
681475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG);
682475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerMEMSET(SDValue Op, SelectionDAG &DAG);
683475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG);
684475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG);
685475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG);
686475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerVAARG(SDValue Op, SelectionDAG &DAG);
687475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerVACOPY(SDValue Op, SelectionDAG &DAG);
688475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG);
689475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG);
690475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG);
691475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerFRAME_TO_ARGS_OFFSET(SDValue Op, SelectionDAG &DAG);
692475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerEH_RETURN(SDValue Op, SelectionDAG &DAG);
693475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerTRAMPOLINE(SDValue Op, SelectionDAG &DAG);
694475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerFLT_ROUNDS_(SDValue Op, SelectionDAG &DAG);
695475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerCTLZ(SDValue Op, SelectionDAG &DAG);
696475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerCTTZ(SDValue Op, SelectionDAG &DAG);
697af9b952627d8fa10412b8cf7319d3e334446547fMon P Wang    SDValue LowerMUL_V2I64(SDValue Op, SelectionDAG &DAG);
69874c376529101acbe141a256d0bf23a44eb454c84Bill Wendling    SDValue LowerXALUO(SDValue Op, SelectionDAG &DAG);
69941ea7e7eb3a6a269f2bfed0bdc191ea046d18e5eBill Wendling
700475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    SDValue LowerCMP_SWAP(SDValue Op, SelectionDAG &DAG);
70171d1bf55a27017fceef25554e02021a3bc47cdb4Dale Johannesen    SDValue LowerLOAD_SUB(SDValue Op, SelectionDAG &DAG);
7021607f05cb7d77d01ce521a30232faa389dbed4e2Duncan Sands    SDValue LowerREADCYCLECOUNTER(SDValue Op, SelectionDAG &DAG);
7031607f05cb7d77d01ce521a30232faa389dbed4e2Duncan Sands
70498ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman    virtual SDValue
70598ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman      LowerFormalArguments(SDValue Chain,
70665c3c8f323198b99b88b109654194540cf9b3fa5Sandeep Patel                           CallingConv::ID CallConv, bool isVarArg,
70798ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman                           const SmallVectorImpl<ISD::InputArg> &Ins,
70898ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman                           DebugLoc dl, SelectionDAG &DAG,
70998ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman                           SmallVectorImpl<SDValue> &InVals);
71098ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman    virtual SDValue
711022d9e1cef7586a80a96446ae8691a37def9bbf4Evan Cheng      LowerCall(SDValue Chain, SDValue Callee,
7120c439eb2c8397996cbccaf2798e598052d9982c8Evan Cheng                CallingConv::ID CallConv, bool isVarArg, bool &isTailCall,
71398ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman                const SmallVectorImpl<ISD::OutputArg> &Outs,
71498ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman                const SmallVectorImpl<ISD::InputArg> &Ins,
71598ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman                DebugLoc dl, SelectionDAG &DAG,
71698ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman                SmallVectorImpl<SDValue> &InVals);
71798ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman
71898ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman    virtual SDValue
71998ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman      LowerReturn(SDValue Chain,
72065c3c8f323198b99b88b109654194540cf9b3fa5Sandeep Patel                  CallingConv::ID CallConv, bool isVarArg,
72198ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman                  const SmallVectorImpl<ISD::OutputArg> &Outs,
72298ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman                  DebugLoc dl, SelectionDAG &DAG);
72398ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman
724b4997aeab74934ffa6fc0409afc4d8704245e372Kenneth Uildriks    virtual bool
725b4997aeab74934ffa6fc0409afc4d8704245e372Kenneth Uildriks      CanLowerReturn(CallingConv::ID CallConv, bool isVarArg,
726b4997aeab74934ffa6fc0409afc4d8704245e372Kenneth Uildriks                     const SmallVectorImpl<EVT> &OutTys,
727b4997aeab74934ffa6fc0409afc4d8704245e372Kenneth Uildriks                     const SmallVectorImpl<ISD::ArgFlagsTy> &ArgsFlags,
728b4997aeab74934ffa6fc0409afc4d8704245e372Kenneth Uildriks                     SelectionDAG &DAG);
729b4997aeab74934ffa6fc0409afc4d8704245e372Kenneth Uildriks
7301607f05cb7d77d01ce521a30232faa389dbed4e2Duncan Sands    void ReplaceATOMIC_BINARY_64(SDNode *N, SmallVectorImpl<SDValue> &Results,
7311607f05cb7d77d01ce521a30232faa389dbed4e2Duncan Sands                                 SelectionDAG &DAG, unsigned NewOp);
7321607f05cb7d77d01ce521a30232faa389dbed4e2Duncan Sands
733eacf2dc4bb64b5be2ab33339e81b526aa76adfbbDale Johannesen    SDValue EmitTargetCodeForMemset(SelectionDAG &DAG, DebugLoc dl,
7346f287b22d2e57600b4cd5dc209d0d869e7736c0bBill Wendling                                    SDValue Chain,
7356f287b22d2e57600b4cd5dc209d0d869e7736c0bBill Wendling                                    SDValue Dst, SDValue Src,
7366f287b22d2e57600b4cd5dc209d0d869e7736c0bBill Wendling                                    SDValue Size, unsigned Align,
7376158d8492cc021bb47caee6d4755135ef1d855a4Bill Wendling                                    const Value *DstSV, uint64_t DstSVOff);
738eacf2dc4bb64b5be2ab33339e81b526aa76adfbbDale Johannesen    SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl,
7396f287b22d2e57600b4cd5dc209d0d869e7736c0bBill Wendling                                    SDValue Chain,
7406f287b22d2e57600b4cd5dc209d0d869e7736c0bBill Wendling                                    SDValue Dst, SDValue Src,
7416f287b22d2e57600b4cd5dc209d0d869e7736c0bBill Wendling                                    SDValue Size, unsigned Align,
7426f287b22d2e57600b4cd5dc209d0d869e7736c0bBill Wendling                                    bool AlwaysInline,
7436f287b22d2e57600b4cd5dc209d0d869e7736c0bBill Wendling                                    const Value *DstSV, uint64_t DstSVOff,
7446f287b22d2e57600b4cd5dc209d0d869e7736c0bBill Wendling                                    const Value *SrcSV, uint64_t SrcSVOff);
74563307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang
746b120ab4057fc66ce11ee1f108af9dbbeafa3fed9Eric Christopher    /// Utility function to emit string processing sse4.2 instructions
747b120ab4057fc66ce11ee1f108af9dbbeafa3fed9Eric Christopher    /// that return in xmm0.
748431f775bab2c1ca144e3c9c6b1e3c0767bfacc33Evan Cheng    /// This takes the instruction to expand, the associated machine basic
749431f775bab2c1ca144e3c9c6b1e3c0767bfacc33Evan Cheng    /// block, the number of args, and whether or not the second arg is
750431f775bab2c1ca144e3c9c6b1e3c0767bfacc33Evan Cheng    /// in memory or not.
751b120ab4057fc66ce11ee1f108af9dbbeafa3fed9Eric Christopher    MachineBasicBlock *EmitPCMP(MachineInstr *BInstr, MachineBasicBlock *BB,
752b120ab4057fc66ce11ee1f108af9dbbeafa3fed9Eric Christopher				unsigned argNum, bool inMem) const;
753b120ab4057fc66ce11ee1f108af9dbbeafa3fed9Eric Christopher
75463307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang    /// Utility function to emit atomic bitwise operations (and, or, xor).
755431f775bab2c1ca144e3c9c6b1e3c0767bfacc33Evan Cheng    /// It takes the bitwise instruction to expand, the associated machine basic
756431f775bab2c1ca144e3c9c6b1e3c0767bfacc33Evan Cheng    /// block, and the associated X86 opcodes for reg/reg and reg/imm.
75763307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang    MachineBasicBlock *EmitAtomicBitwiseWithCustomInserter(
75863307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang                                                    MachineInstr *BInstr,
75963307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang                                                    MachineBasicBlock *BB,
76063307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang                                                    unsigned regOpc,
761507a58ac9b20ddcea2e56a014be26b8f8cc0ecb8Andrew Lenharth                                                    unsigned immOpc,
762140be2dfb76928cb660b7de23f8310d76ca794b5Dale Johannesen                                                    unsigned loadOpc,
763140be2dfb76928cb660b7de23f8310d76ca794b5Dale Johannesen                                                    unsigned cxchgOpc,
764140be2dfb76928cb660b7de23f8310d76ca794b5Dale Johannesen                                                    unsigned copyOpc,
765140be2dfb76928cb660b7de23f8310d76ca794b5Dale Johannesen                                                    unsigned notOpc,
766140be2dfb76928cb660b7de23f8310d76ca794b5Dale Johannesen                                                    unsigned EAXreg,
767140be2dfb76928cb660b7de23f8310d76ca794b5Dale Johannesen                                                    TargetRegisterClass *RC,
7681fdbc1dd4e9cb42c79a30e8dc308c322e923cc52Dan Gohman                                                    bool invSrc = false) const;
76948c1bc2ace6481d3272ab5c18e1f19352c563be8Dale Johannesen
77048c1bc2ace6481d3272ab5c18e1f19352c563be8Dale Johannesen    MachineBasicBlock *EmitAtomicBit6432WithCustomInserter(
77148c1bc2ace6481d3272ab5c18e1f19352c563be8Dale Johannesen                                                    MachineInstr *BInstr,
77248c1bc2ace6481d3272ab5c18e1f19352c563be8Dale Johannesen                                                    MachineBasicBlock *BB,
77348c1bc2ace6481d3272ab5c18e1f19352c563be8Dale Johannesen                                                    unsigned regOpcL,
77448c1bc2ace6481d3272ab5c18e1f19352c563be8Dale Johannesen                                                    unsigned regOpcH,
77548c1bc2ace6481d3272ab5c18e1f19352c563be8Dale Johannesen                                                    unsigned immOpcL,
77648c1bc2ace6481d3272ab5c18e1f19352c563be8Dale Johannesen                                                    unsigned immOpcH,
7771fdbc1dd4e9cb42c79a30e8dc308c322e923cc52Dan Gohman                                                    bool invSrc = false) const;
77863307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang
77963307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang    /// Utility function to emit atomic min and max.  It takes the min/max
780bddc442a00c2216834499f10c12d023f1751104cBill Wendling    /// instruction to expand, the associated basic block, and the associated
781bddc442a00c2216834499f10c12d023f1751104cBill Wendling    /// cmov opcode for moving the min or max value.
78263307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang    MachineBasicBlock *EmitAtomicMinMaxWithCustomInserter(MachineInstr *BInstr,
78363307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang                                                          MachineBasicBlock *BB,
7841fdbc1dd4e9cb42c79a30e8dc308c322e923cc52Dan Gohman                                                        unsigned cmovOpc) const;
785076aee32e86bc4a0c096262b3261923f25220dc6Dan Gohman
786d6708eade079c30b0790789a00a8d737d84f52b7Dan Gohman    /// Utility function to emit the xmm reg save portion of va_start.
787d6708eade079c30b0790789a00a8d737d84f52b7Dan Gohman    MachineBasicBlock *EmitVAStartSaveXMMRegsWithCustomInserter(
788d6708eade079c30b0790789a00a8d737d84f52b7Dan Gohman                                                   MachineInstr *BInstr,
789d6708eade079c30b0790789a00a8d737d84f52b7Dan Gohman                                                   MachineBasicBlock *BB) const;
790d6708eade079c30b0790789a00a8d737d84f52b7Dan Gohman
79152600972832cb4ae8f4c63802f3764cbfbcb203dChris Lattner    MachineBasicBlock *EmitLoweredSelect(MachineInstr *I,
792ce31910eae5bd4896fa6c27798e7b26885691d3bEvan Cheng                                         MachineBasicBlock *BB,
793ce31910eae5bd4896fa6c27798e7b26885691d3bEvan Cheng                    DenseMap<MachineBasicBlock*, MachineBasicBlock*> *EM) const;
794043f3c2a0e286dcfd4cc5a16bf006e3c45929516Anton Korobeynikov
795043f3c2a0e286dcfd4cc5a16bf006e3c45929516Anton Korobeynikov    MachineBasicBlock *EmitLoweredMingwAlloca(MachineInstr *MI,
796043f3c2a0e286dcfd4cc5a16bf006e3c45929516Anton Korobeynikov                                              MachineBasicBlock *BB,
797043f3c2a0e286dcfd4cc5a16bf006e3c45929516Anton Korobeynikov                    DenseMap<MachineBasicBlock*, MachineBasicBlock*> *EM) const;
798043f3c2a0e286dcfd4cc5a16bf006e3c45929516Anton Korobeynikov
799076aee32e86bc4a0c096262b3261923f25220dc6Dan Gohman    /// Emit nodes that will be selected as "test Op0,Op0", or something
8003112581441cd22ac955b1af2d08effe3bab975daDan Gohman    /// equivalent, for use with the given x86 condition code.
8013112581441cd22ac955b1af2d08effe3bab975daDan Gohman    SDValue EmitTest(SDValue Op0, unsigned X86CC, SelectionDAG &DAG);
802076aee32e86bc4a0c096262b3261923f25220dc6Dan Gohman
803076aee32e86bc4a0c096262b3261923f25220dc6Dan Gohman    /// Emit nodes that will be selected as "cmp Op0,Op1", or something
8043112581441cd22ac955b1af2d08effe3bab975daDan Gohman    /// equivalent, for use with the given x86 condition code.
8053112581441cd22ac955b1af2d08effe3bab975daDan Gohman    SDValue EmitCmp(SDValue Op0, SDValue Op1, unsigned X86CC,
8063112581441cd22ac955b1af2d08effe3bab975daDan Gohman                    SelectionDAG &DAG);
807dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner  };
808c3f44b0d636ff9a6d706ea9ac17ae77c8fa8aeffEvan Cheng
809c3f44b0d636ff9a6d706ea9ac17ae77c8fa8aeffEvan Cheng  namespace X86 {
8103df24e667f04a7003342b534310919abc9c87418Dan Gohman    FastISel *createFastISel(MachineFunction &mf,
81183489bb7700c69b7a4a8da59365c42d3f5c8129bDevang Patel                           MachineModuleInfo *mmi, DwarfWriter *dw,
8123df24e667f04a7003342b534310919abc9c87418Dan Gohman                           DenseMap<const Value *, unsigned> &,
8130586d91bb3e516d5826826522d9a90ed6ef74d86Dan Gohman                           DenseMap<const BasicBlock *, MachineBasicBlock *> &,
814dd5b58ad7be78be90390074f0df138778af5c895Dan Gohman                           DenseMap<const AllocaInst *, int> &
815dd5b58ad7be78be90390074f0df138778af5c895Dan Gohman#ifndef NDEBUG
816dd5b58ad7be78be90390074f0df138778af5c895Dan Gohman                           , SmallSet<Instruction*, 8> &
817dd5b58ad7be78be90390074f0df138778af5c895Dan Gohman#endif
818dd5b58ad7be78be90390074f0df138778af5c895Dan Gohman                           );
819c3f44b0d636ff9a6d706ea9ac17ae77c8fa8aeffEvan Cheng  }
820dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner}
821dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner
822dbdbf0ce2eef7b6585397121f56d3845e04866d1Chris Lattner#endif    // X86ISELLOWERING_H
823