TargetLoweringBase.cpp revision 13bbe1f52e8d57151e2730db49094e1c62a4c793
169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer//===-- TargetLoweringBase.cpp - Implement the TargetLoweringBase class ---===//
269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer//
369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer//                     The LLVM Compiler Infrastructure
469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer//
569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer// This file is distributed under the University of Illinois Open Source
669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer// License. See LICENSE.TXT for details.
769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer//
869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer//===----------------------------------------------------------------------===//
969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer//
1069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer// This implements the TargetLoweringBase class.
1169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer//
1269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer//===----------------------------------------------------------------------===//
1369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
1469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/Target/TargetLowering.h"
1569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/ADT/BitVector.h"
1669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/ADT/STLExtras.h"
1786cdbc9c29a572d422815f55fd89ff7510d1e3e8Paul Redmond#include "llvm/ADT/Triple.h"
1869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/CodeGen/Analysis.h"
1969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/CodeGen/MachineFrameInfo.h"
2069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/CodeGen/MachineFunction.h"
2169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/CodeGen/MachineJumpTableInfo.h"
2269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/IR/DataLayout.h"
2369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/IR/DerivedTypes.h"
2469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/IR/GlobalVariable.h"
2569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/MC/MCAsmInfo.h"
2669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/MC/MCExpr.h"
2769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/Support/CommandLine.h"
2869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/Support/ErrorHandling.h"
2969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/Support/MathExtras.h"
3069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/Target/TargetLoweringObjectFile.h"
3169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/Target/TargetMachine.h"
3269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/Target/TargetRegisterInfo.h"
3369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include <cctype>
3469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramerusing namespace llvm;
3569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
3669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// InitLibcallNames - Set default libcall names.
3769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer///
3886cdbc9c29a572d422815f55fd89ff7510d1e3e8Paul Redmondstatic void InitLibcallNames(const char **Names, const TargetMachine &TM) {
3969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SHL_I16] = "__ashlhi3";
4069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SHL_I32] = "__ashlsi3";
4169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SHL_I64] = "__ashldi3";
4269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SHL_I128] = "__ashlti3";
4369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SRL_I16] = "__lshrhi3";
4469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SRL_I32] = "__lshrsi3";
4569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SRL_I64] = "__lshrdi3";
4669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SRL_I128] = "__lshrti3";
4769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SRA_I16] = "__ashrhi3";
4869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SRA_I32] = "__ashrsi3";
4969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SRA_I64] = "__ashrdi3";
5069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SRA_I128] = "__ashrti3";
5169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::MUL_I8] = "__mulqi3";
5269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::MUL_I16] = "__mulhi3";
5369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::MUL_I32] = "__mulsi3";
5469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::MUL_I64] = "__muldi3";
5569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::MUL_I128] = "__multi3";
5669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::MULO_I32] = "__mulosi4";
5769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::MULO_I64] = "__mulodi4";
5869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::MULO_I128] = "__muloti4";
5969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SDIV_I8] = "__divqi3";
6069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SDIV_I16] = "__divhi3";
6169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SDIV_I32] = "__divsi3";
6269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SDIV_I64] = "__divdi3";
6369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SDIV_I128] = "__divti3";
6469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UDIV_I8] = "__udivqi3";
6569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UDIV_I16] = "__udivhi3";
6669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UDIV_I32] = "__udivsi3";
6769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UDIV_I64] = "__udivdi3";
6869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UDIV_I128] = "__udivti3";
6969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SREM_I8] = "__modqi3";
7069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SREM_I16] = "__modhi3";
7169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SREM_I32] = "__modsi3";
7269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SREM_I64] = "__moddi3";
7369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SREM_I128] = "__modti3";
7469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UREM_I8] = "__umodqi3";
7569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UREM_I16] = "__umodhi3";
7669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UREM_I32] = "__umodsi3";
7769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UREM_I64] = "__umoddi3";
7869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UREM_I128] = "__umodti3";
7969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
8069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // These are generally not available.
8169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SDIVREM_I8] = 0;
8269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SDIVREM_I16] = 0;
8369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SDIVREM_I32] = 0;
8469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SDIVREM_I64] = 0;
8569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SDIVREM_I128] = 0;
8669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UDIVREM_I8] = 0;
8769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UDIVREM_I16] = 0;
8869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UDIVREM_I32] = 0;
8969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UDIVREM_I64] = 0;
9069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UDIVREM_I128] = 0;
9169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
9269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::NEG_I32] = "__negsi2";
9369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::NEG_I64] = "__negdi2";
9469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::ADD_F32] = "__addsf3";
9569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::ADD_F64] = "__adddf3";
9669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::ADD_F80] = "__addxf3";
9769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::ADD_F128] = "__addtf3";
9869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::ADD_PPCF128] = "__gcc_qadd";
9969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SUB_F32] = "__subsf3";
10069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SUB_F64] = "__subdf3";
10169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SUB_F80] = "__subxf3";
10269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SUB_F128] = "__subtf3";
10369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SUB_PPCF128] = "__gcc_qsub";
10469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::MUL_F32] = "__mulsf3";
10569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::MUL_F64] = "__muldf3";
10669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::MUL_F80] = "__mulxf3";
10769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::MUL_F128] = "__multf3";
10869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::MUL_PPCF128] = "__gcc_qmul";
10969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::DIV_F32] = "__divsf3";
11069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::DIV_F64] = "__divdf3";
11169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::DIV_F80] = "__divxf3";
11269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::DIV_F128] = "__divtf3";
11369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::DIV_PPCF128] = "__gcc_qdiv";
11469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::REM_F32] = "fmodf";
11569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::REM_F64] = "fmod";
11669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::REM_F80] = "fmodl";
11769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::REM_F128] = "fmodl";
11869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::REM_PPCF128] = "fmodl";
11969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FMA_F32] = "fmaf";
12069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FMA_F64] = "fma";
12169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FMA_F80] = "fmal";
12269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FMA_F128] = "fmal";
12369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FMA_PPCF128] = "fmal";
12469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::POWI_F32] = "__powisf2";
12569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::POWI_F64] = "__powidf2";
12669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::POWI_F80] = "__powixf2";
12769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::POWI_F128] = "__powitf2";
12869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::POWI_PPCF128] = "__powitf2";
12969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SQRT_F32] = "sqrtf";
13069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SQRT_F64] = "sqrt";
13169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SQRT_F80] = "sqrtl";
13269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SQRT_F128] = "sqrtl";
13369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SQRT_PPCF128] = "sqrtl";
13469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::LOG_F32] = "logf";
13569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::LOG_F64] = "log";
13669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::LOG_F80] = "logl";
13769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::LOG_F128] = "logl";
13869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::LOG_PPCF128] = "logl";
13969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::LOG2_F32] = "log2f";
14069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::LOG2_F64] = "log2";
14169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::LOG2_F80] = "log2l";
14269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::LOG2_F128] = "log2l";
14369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::LOG2_PPCF128] = "log2l";
14469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::LOG10_F32] = "log10f";
14569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::LOG10_F64] = "log10";
14669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::LOG10_F80] = "log10l";
14769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::LOG10_F128] = "log10l";
14869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::LOG10_PPCF128] = "log10l";
14969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::EXP_F32] = "expf";
15069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::EXP_F64] = "exp";
15169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::EXP_F80] = "expl";
15269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::EXP_F128] = "expl";
15369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::EXP_PPCF128] = "expl";
15469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::EXP2_F32] = "exp2f";
15569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::EXP2_F64] = "exp2";
15669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::EXP2_F80] = "exp2l";
15769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::EXP2_F128] = "exp2l";
15869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::EXP2_PPCF128] = "exp2l";
15969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SIN_F32] = "sinf";
16069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SIN_F64] = "sin";
16169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SIN_F80] = "sinl";
16269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SIN_F128] = "sinl";
16369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SIN_PPCF128] = "sinl";
16469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::COS_F32] = "cosf";
16569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::COS_F64] = "cos";
16669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::COS_F80] = "cosl";
16769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::COS_F128] = "cosl";
16869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::COS_PPCF128] = "cosl";
16969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::POW_F32] = "powf";
17069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::POW_F64] = "pow";
17169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::POW_F80] = "powl";
17269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::POW_F128] = "powl";
17369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::POW_PPCF128] = "powl";
17469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::CEIL_F32] = "ceilf";
17569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::CEIL_F64] = "ceil";
17669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::CEIL_F80] = "ceill";
17769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::CEIL_F128] = "ceill";
17869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::CEIL_PPCF128] = "ceill";
17969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::TRUNC_F32] = "truncf";
18069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::TRUNC_F64] = "trunc";
18169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::TRUNC_F80] = "truncl";
18269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::TRUNC_F128] = "truncl";
18369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::TRUNC_PPCF128] = "truncl";
18469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::RINT_F32] = "rintf";
18569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::RINT_F64] = "rint";
18669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::RINT_F80] = "rintl";
18769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::RINT_F128] = "rintl";
18869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::RINT_PPCF128] = "rintl";
18969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::NEARBYINT_F32] = "nearbyintf";
19069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::NEARBYINT_F64] = "nearbyint";
19169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::NEARBYINT_F80] = "nearbyintl";
19269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::NEARBYINT_F128] = "nearbyintl";
19369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::NEARBYINT_PPCF128] = "nearbyintl";
19469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FLOOR_F32] = "floorf";
19569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FLOOR_F64] = "floor";
19669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FLOOR_F80] = "floorl";
19769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FLOOR_F128] = "floorl";
19869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FLOOR_PPCF128] = "floorl";
19969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::COPYSIGN_F32] = "copysignf";
20069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::COPYSIGN_F64] = "copysign";
20169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::COPYSIGN_F80] = "copysignl";
20269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::COPYSIGN_F128] = "copysignl";
20369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::COPYSIGN_PPCF128] = "copysignl";
20469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPEXT_F64_F128] = "__extenddftf2";
20569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPEXT_F32_F128] = "__extendsftf2";
20669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPEXT_F32_F64] = "__extendsfdf2";
20769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPEXT_F16_F32] = "__gnu_h2f_ieee";
20869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPROUND_F32_F16] = "__gnu_f2h_ieee";
20969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPROUND_F64_F32] = "__truncdfsf2";
21069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPROUND_F80_F32] = "__truncxfsf2";
21169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPROUND_F128_F32] = "__trunctfsf2";
21269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPROUND_PPCF128_F32] = "__trunctfsf2";
21369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPROUND_F80_F64] = "__truncxfdf2";
21469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPROUND_F128_F64] = "__trunctfdf2";
21569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPROUND_PPCF128_F64] = "__trunctfdf2";
21669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOSINT_F32_I8] = "__fixsfqi";
21769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOSINT_F32_I16] = "__fixsfhi";
21869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOSINT_F32_I32] = "__fixsfsi";
21969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOSINT_F32_I64] = "__fixsfdi";
22069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOSINT_F32_I128] = "__fixsfti";
22169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOSINT_F64_I8] = "__fixdfqi";
22269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOSINT_F64_I16] = "__fixdfhi";
22369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOSINT_F64_I32] = "__fixdfsi";
22469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOSINT_F64_I64] = "__fixdfdi";
22569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOSINT_F64_I128] = "__fixdfti";
22669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOSINT_F80_I32] = "__fixxfsi";
22769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOSINT_F80_I64] = "__fixxfdi";
22869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOSINT_F80_I128] = "__fixxfti";
22969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOSINT_F128_I32] = "__fixtfsi";
23069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOSINT_F128_I64] = "__fixtfdi";
23169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOSINT_F128_I128] = "__fixtfti";
23269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOSINT_PPCF128_I32] = "__fixtfsi";
23369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOSINT_PPCF128_I64] = "__fixtfdi";
23469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOSINT_PPCF128_I128] = "__fixtfti";
23569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOUINT_F32_I8] = "__fixunssfqi";
23669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOUINT_F32_I16] = "__fixunssfhi";
23769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOUINT_F32_I32] = "__fixunssfsi";
23869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOUINT_F32_I64] = "__fixunssfdi";
23969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOUINT_F32_I128] = "__fixunssfti";
24069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOUINT_F64_I8] = "__fixunsdfqi";
24169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOUINT_F64_I16] = "__fixunsdfhi";
24269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOUINT_F64_I32] = "__fixunsdfsi";
24369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOUINT_F64_I64] = "__fixunsdfdi";
24469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOUINT_F64_I128] = "__fixunsdfti";
24569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOUINT_F80_I32] = "__fixunsxfsi";
24669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOUINT_F80_I64] = "__fixunsxfdi";
24769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOUINT_F80_I128] = "__fixunsxfti";
24869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOUINT_F128_I32] = "__fixunstfsi";
24969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOUINT_F128_I64] = "__fixunstfdi";
25069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOUINT_F128_I128] = "__fixunstfti";
25169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOUINT_PPCF128_I32] = "__fixunstfsi";
25269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOUINT_PPCF128_I64] = "__fixunstfdi";
25369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::FPTOUINT_PPCF128_I128] = "__fixunstfti";
25469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SINTTOFP_I32_F32] = "__floatsisf";
25569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SINTTOFP_I32_F64] = "__floatsidf";
25669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SINTTOFP_I32_F80] = "__floatsixf";
25769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SINTTOFP_I32_F128] = "__floatsitf";
25869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SINTTOFP_I32_PPCF128] = "__floatsitf";
25969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SINTTOFP_I64_F32] = "__floatdisf";
26069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SINTTOFP_I64_F64] = "__floatdidf";
26169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SINTTOFP_I64_F80] = "__floatdixf";
26269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SINTTOFP_I64_F128] = "__floatditf";
26369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SINTTOFP_I64_PPCF128] = "__floatditf";
26469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SINTTOFP_I128_F32] = "__floattisf";
26569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SINTTOFP_I128_F64] = "__floattidf";
26669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SINTTOFP_I128_F80] = "__floattixf";
26769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SINTTOFP_I128_F128] = "__floattitf";
26869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SINTTOFP_I128_PPCF128] = "__floattitf";
26969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UINTTOFP_I32_F32] = "__floatunsisf";
27069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UINTTOFP_I32_F64] = "__floatunsidf";
27169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UINTTOFP_I32_F80] = "__floatunsixf";
27269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UINTTOFP_I32_F128] = "__floatunsitf";
27369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UINTTOFP_I32_PPCF128] = "__floatunsitf";
27469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UINTTOFP_I64_F32] = "__floatundisf";
27569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UINTTOFP_I64_F64] = "__floatundidf";
27669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UINTTOFP_I64_F80] = "__floatundixf";
27769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UINTTOFP_I64_F128] = "__floatunditf";
27869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UINTTOFP_I64_PPCF128] = "__floatunditf";
27969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UINTTOFP_I128_F32] = "__floatuntisf";
28069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UINTTOFP_I128_F64] = "__floatuntidf";
28169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UINTTOFP_I128_F80] = "__floatuntixf";
28269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UINTTOFP_I128_F128] = "__floatuntitf";
28369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UINTTOFP_I128_PPCF128] = "__floatuntitf";
28469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::OEQ_F32] = "__eqsf2";
28569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::OEQ_F64] = "__eqdf2";
28669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::OEQ_F128] = "__eqtf2";
28769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UNE_F32] = "__nesf2";
28869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UNE_F64] = "__nedf2";
28969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UNE_F128] = "__netf2";
29069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::OGE_F32] = "__gesf2";
29169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::OGE_F64] = "__gedf2";
29269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::OGE_F128] = "__getf2";
29369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::OLT_F32] = "__ltsf2";
29469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::OLT_F64] = "__ltdf2";
29569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::OLT_F128] = "__lttf2";
29669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::OLE_F32] = "__lesf2";
29769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::OLE_F64] = "__ledf2";
29869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::OLE_F128] = "__letf2";
29969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::OGT_F32] = "__gtsf2";
30069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::OGT_F64] = "__gtdf2";
30169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::OGT_F128] = "__gttf2";
30269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UO_F32] = "__unordsf2";
30369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UO_F64] = "__unorddf2";
30469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UO_F128] = "__unordtf2";
30569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::O_F32] = "__unordsf2";
30669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::O_F64] = "__unorddf2";
30769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::O_F128] = "__unordtf2";
30869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::MEMCPY] = "memcpy";
30969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::MEMMOVE] = "memmove";
31069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::MEMSET] = "memset";
31169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::UNWIND_RESUME] = "_Unwind_Resume";
31269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_VAL_COMPARE_AND_SWAP_1] = "__sync_val_compare_and_swap_1";
31369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_VAL_COMPARE_AND_SWAP_2] = "__sync_val_compare_and_swap_2";
31469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_VAL_COMPARE_AND_SWAP_4] = "__sync_val_compare_and_swap_4";
31569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_VAL_COMPARE_AND_SWAP_8] = "__sync_val_compare_and_swap_8";
31669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_LOCK_TEST_AND_SET_1] = "__sync_lock_test_and_set_1";
31769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_LOCK_TEST_AND_SET_2] = "__sync_lock_test_and_set_2";
31869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_LOCK_TEST_AND_SET_4] = "__sync_lock_test_and_set_4";
31969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_LOCK_TEST_AND_SET_8] = "__sync_lock_test_and_set_8";
32069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_FETCH_AND_ADD_1] = "__sync_fetch_and_add_1";
32169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_FETCH_AND_ADD_2] = "__sync_fetch_and_add_2";
32269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_FETCH_AND_ADD_4] = "__sync_fetch_and_add_4";
32369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_FETCH_AND_ADD_8] = "__sync_fetch_and_add_8";
32469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_FETCH_AND_SUB_1] = "__sync_fetch_and_sub_1";
32569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_FETCH_AND_SUB_2] = "__sync_fetch_and_sub_2";
32669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_FETCH_AND_SUB_4] = "__sync_fetch_and_sub_4";
32769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_FETCH_AND_SUB_8] = "__sync_fetch_and_sub_8";
32869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_FETCH_AND_AND_1] = "__sync_fetch_and_and_1";
32969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_FETCH_AND_AND_2] = "__sync_fetch_and_and_2";
33069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_FETCH_AND_AND_4] = "__sync_fetch_and_and_4";
33169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_FETCH_AND_AND_8] = "__sync_fetch_and_and_8";
33269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_FETCH_AND_OR_1] = "__sync_fetch_and_or_1";
33369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_FETCH_AND_OR_2] = "__sync_fetch_and_or_2";
33469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_FETCH_AND_OR_4] = "__sync_fetch_and_or_4";
33569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_FETCH_AND_OR_8] = "__sync_fetch_and_or_8";
33669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_FETCH_AND_XOR_1] = "__sync_fetch_and_xor_1";
33769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_FETCH_AND_XOR_2] = "__sync_fetch_and_xor_2";
33869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_FETCH_AND_XOR_4] = "__sync_fetch_and_xor_4";
33969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_FETCH_AND_XOR_8] = "__sync_fetch_and_xor_8";
34069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_FETCH_AND_NAND_1] = "__sync_fetch_and_nand_1";
34169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_FETCH_AND_NAND_2] = "__sync_fetch_and_nand_2";
34269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_FETCH_AND_NAND_4] = "__sync_fetch_and_nand_4";
34369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  Names[RTLIB::SYNC_FETCH_AND_NAND_8] = "__sync_fetch_and_nand_8";
3448688a58c53b46d2dda9bf50dafd5195790a7ed58Evan Cheng
34586cdbc9c29a572d422815f55fd89ff7510d1e3e8Paul Redmond  if (Triple(TM.getTargetTriple()).getEnvironment() == Triple::GNU) {
34686cdbc9c29a572d422815f55fd89ff7510d1e3e8Paul Redmond    Names[RTLIB::SINCOS_F32] = "sincosf";
34786cdbc9c29a572d422815f55fd89ff7510d1e3e8Paul Redmond    Names[RTLIB::SINCOS_F64] = "sincos";
34886cdbc9c29a572d422815f55fd89ff7510d1e3e8Paul Redmond    Names[RTLIB::SINCOS_F80] = "sincosl";
34986cdbc9c29a572d422815f55fd89ff7510d1e3e8Paul Redmond    Names[RTLIB::SINCOS_F128] = "sincosl";
35086cdbc9c29a572d422815f55fd89ff7510d1e3e8Paul Redmond    Names[RTLIB::SINCOS_PPCF128] = "sincosl";
35186cdbc9c29a572d422815f55fd89ff7510d1e3e8Paul Redmond  } else {
35286cdbc9c29a572d422815f55fd89ff7510d1e3e8Paul Redmond    // These are generally not available.
35386cdbc9c29a572d422815f55fd89ff7510d1e3e8Paul Redmond    Names[RTLIB::SINCOS_F32] = 0;
35486cdbc9c29a572d422815f55fd89ff7510d1e3e8Paul Redmond    Names[RTLIB::SINCOS_F64] = 0;
35586cdbc9c29a572d422815f55fd89ff7510d1e3e8Paul Redmond    Names[RTLIB::SINCOS_F80] = 0;
35686cdbc9c29a572d422815f55fd89ff7510d1e3e8Paul Redmond    Names[RTLIB::SINCOS_F128] = 0;
35786cdbc9c29a572d422815f55fd89ff7510d1e3e8Paul Redmond    Names[RTLIB::SINCOS_PPCF128] = 0;
35886cdbc9c29a572d422815f55fd89ff7510d1e3e8Paul Redmond  }
35969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer}
36069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
36169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// InitLibcallCallingConvs - Set default libcall CallingConvs.
36269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer///
36369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramerstatic void InitLibcallCallingConvs(CallingConv::ID *CCs) {
36469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  for (int i = 0; i < RTLIB::UNKNOWN_LIBCALL; ++i) {
36569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    CCs[i] = CallingConv::C;
36669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  }
36769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer}
36869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
36969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// getFPEXT - Return the FPEXT_*_* value for the given types, or
37069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// UNKNOWN_LIBCALL if there is none.
37169e42dbd006c0afb732067ece7327988b1e24c01Benjamin KramerRTLIB::Libcall RTLIB::getFPEXT(EVT OpVT, EVT RetVT) {
37269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  if (OpVT == MVT::f32) {
37369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::f64)
37469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPEXT_F32_F64;
37569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::f128)
37669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPEXT_F32_F128;
37769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  } else if (OpVT == MVT::f64) {
37869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::f128)
37969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPEXT_F64_F128;
38069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  }
38169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
38269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  return UNKNOWN_LIBCALL;
38369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer}
38469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
38569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// getFPROUND - Return the FPROUND_*_* value for the given types, or
38669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// UNKNOWN_LIBCALL if there is none.
38769e42dbd006c0afb732067ece7327988b1e24c01Benjamin KramerRTLIB::Libcall RTLIB::getFPROUND(EVT OpVT, EVT RetVT) {
38869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  if (RetVT == MVT::f32) {
38969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (OpVT == MVT::f64)
39069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPROUND_F64_F32;
39169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (OpVT == MVT::f80)
39269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPROUND_F80_F32;
39369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (OpVT == MVT::f128)
39469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPROUND_F128_F32;
39569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (OpVT == MVT::ppcf128)
39669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPROUND_PPCF128_F32;
39769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  } else if (RetVT == MVT::f64) {
39869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (OpVT == MVT::f80)
39969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPROUND_F80_F64;
40069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (OpVT == MVT::f128)
40169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPROUND_F128_F64;
40269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (OpVT == MVT::ppcf128)
40369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPROUND_PPCF128_F64;
40469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  }
40569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
40669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  return UNKNOWN_LIBCALL;
40769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer}
40869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
40969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// getFPTOSINT - Return the FPTOSINT_*_* value for the given types, or
41069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// UNKNOWN_LIBCALL if there is none.
41169e42dbd006c0afb732067ece7327988b1e24c01Benjamin KramerRTLIB::Libcall RTLIB::getFPTOSINT(EVT OpVT, EVT RetVT) {
41269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  if (OpVT == MVT::f32) {
41369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i8)
41469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOSINT_F32_I8;
41569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i16)
41669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOSINT_F32_I16;
41769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i32)
41869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOSINT_F32_I32;
41969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i64)
42069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOSINT_F32_I64;
42169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i128)
42269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOSINT_F32_I128;
42369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  } else if (OpVT == MVT::f64) {
42469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i8)
42569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOSINT_F64_I8;
42669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i16)
42769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOSINT_F64_I16;
42869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i32)
42969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOSINT_F64_I32;
43069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i64)
43169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOSINT_F64_I64;
43269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i128)
43369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOSINT_F64_I128;
43469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  } else if (OpVT == MVT::f80) {
43569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i32)
43669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOSINT_F80_I32;
43769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i64)
43869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOSINT_F80_I64;
43969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i128)
44069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOSINT_F80_I128;
44169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  } else if (OpVT == MVT::f128) {
44269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i32)
44369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOSINT_F128_I32;
44469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i64)
44569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOSINT_F128_I64;
44669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i128)
44769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOSINT_F128_I128;
44869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  } else if (OpVT == MVT::ppcf128) {
44969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i32)
45069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOSINT_PPCF128_I32;
45169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i64)
45269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOSINT_PPCF128_I64;
45369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i128)
45469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOSINT_PPCF128_I128;
45569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  }
45669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  return UNKNOWN_LIBCALL;
45769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer}
45869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
45969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// getFPTOUINT - Return the FPTOUINT_*_* value for the given types, or
46069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// UNKNOWN_LIBCALL if there is none.
46169e42dbd006c0afb732067ece7327988b1e24c01Benjamin KramerRTLIB::Libcall RTLIB::getFPTOUINT(EVT OpVT, EVT RetVT) {
46269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  if (OpVT == MVT::f32) {
46369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i8)
46469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOUINT_F32_I8;
46569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i16)
46669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOUINT_F32_I16;
46769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i32)
46869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOUINT_F32_I32;
46969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i64)
47069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOUINT_F32_I64;
47169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i128)
47269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOUINT_F32_I128;
47369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  } else if (OpVT == MVT::f64) {
47469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i8)
47569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOUINT_F64_I8;
47669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i16)
47769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOUINT_F64_I16;
47869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i32)
47969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOUINT_F64_I32;
48069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i64)
48169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOUINT_F64_I64;
48269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i128)
48369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOUINT_F64_I128;
48469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  } else if (OpVT == MVT::f80) {
48569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i32)
48669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOUINT_F80_I32;
48769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i64)
48869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOUINT_F80_I64;
48969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i128)
49069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOUINT_F80_I128;
49169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  } else if (OpVT == MVT::f128) {
49269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i32)
49369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOUINT_F128_I32;
49469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i64)
49569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOUINT_F128_I64;
49669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i128)
49769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOUINT_F128_I128;
49869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  } else if (OpVT == MVT::ppcf128) {
49969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i32)
50069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOUINT_PPCF128_I32;
50169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i64)
50269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOUINT_PPCF128_I64;
50369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::i128)
50469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return FPTOUINT_PPCF128_I128;
50569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  }
50669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  return UNKNOWN_LIBCALL;
50769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer}
50869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
50969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// getSINTTOFP - Return the SINTTOFP_*_* value for the given types, or
51069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// UNKNOWN_LIBCALL if there is none.
51169e42dbd006c0afb732067ece7327988b1e24c01Benjamin KramerRTLIB::Libcall RTLIB::getSINTTOFP(EVT OpVT, EVT RetVT) {
51269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  if (OpVT == MVT::i32) {
51369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::f32)
51469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return SINTTOFP_I32_F32;
51569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::f64)
51669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return SINTTOFP_I32_F64;
51769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::f80)
51869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return SINTTOFP_I32_F80;
51969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::f128)
52069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return SINTTOFP_I32_F128;
52169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::ppcf128)
52269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return SINTTOFP_I32_PPCF128;
52369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  } else if (OpVT == MVT::i64) {
52469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::f32)
52569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return SINTTOFP_I64_F32;
52669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::f64)
52769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return SINTTOFP_I64_F64;
52869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::f80)
52969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return SINTTOFP_I64_F80;
53069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::f128)
53169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return SINTTOFP_I64_F128;
53269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::ppcf128)
53369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return SINTTOFP_I64_PPCF128;
53469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  } else if (OpVT == MVT::i128) {
53569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::f32)
53669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return SINTTOFP_I128_F32;
53769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::f64)
53869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return SINTTOFP_I128_F64;
53969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::f80)
54069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return SINTTOFP_I128_F80;
54169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::f128)
54269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return SINTTOFP_I128_F128;
54369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::ppcf128)
54469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return SINTTOFP_I128_PPCF128;
54569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  }
54669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  return UNKNOWN_LIBCALL;
54769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer}
54869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
54969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// getUINTTOFP - Return the UINTTOFP_*_* value for the given types, or
55069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// UNKNOWN_LIBCALL if there is none.
55169e42dbd006c0afb732067ece7327988b1e24c01Benjamin KramerRTLIB::Libcall RTLIB::getUINTTOFP(EVT OpVT, EVT RetVT) {
55269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  if (OpVT == MVT::i32) {
55369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::f32)
55469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return UINTTOFP_I32_F32;
55569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::f64)
55669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return UINTTOFP_I32_F64;
55769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::f80)
55869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return UINTTOFP_I32_F80;
55969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::f128)
56069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return UINTTOFP_I32_F128;
56169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::ppcf128)
56269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return UINTTOFP_I32_PPCF128;
56369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  } else if (OpVT == MVT::i64) {
56469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::f32)
56569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return UINTTOFP_I64_F32;
56669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::f64)
56769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return UINTTOFP_I64_F64;
56869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::f80)
56969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return UINTTOFP_I64_F80;
57069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::f128)
57169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return UINTTOFP_I64_F128;
57269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::ppcf128)
57369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return UINTTOFP_I64_PPCF128;
57469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  } else if (OpVT == MVT::i128) {
57569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::f32)
57669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return UINTTOFP_I128_F32;
57769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::f64)
57869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return UINTTOFP_I128_F64;
57969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::f80)
58069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return UINTTOFP_I128_F80;
58169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::f128)
58269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return UINTTOFP_I128_F128;
58369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (RetVT == MVT::ppcf128)
58469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return UINTTOFP_I128_PPCF128;
58569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  }
58669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  return UNKNOWN_LIBCALL;
58769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer}
58869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
58969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// InitCmpLibcallCCs - Set default comparison libcall CC.
59069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer///
59169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramerstatic void InitCmpLibcallCCs(ISD::CondCode *CCs) {
59269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  memset(CCs, ISD::SETCC_INVALID, sizeof(ISD::CondCode)*RTLIB::UNKNOWN_LIBCALL);
59369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  CCs[RTLIB::OEQ_F32] = ISD::SETEQ;
59469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  CCs[RTLIB::OEQ_F64] = ISD::SETEQ;
59569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  CCs[RTLIB::OEQ_F128] = ISD::SETEQ;
59669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  CCs[RTLIB::UNE_F32] = ISD::SETNE;
59769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  CCs[RTLIB::UNE_F64] = ISD::SETNE;
59869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  CCs[RTLIB::UNE_F128] = ISD::SETNE;
59969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  CCs[RTLIB::OGE_F32] = ISD::SETGE;
60069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  CCs[RTLIB::OGE_F64] = ISD::SETGE;
60169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  CCs[RTLIB::OGE_F128] = ISD::SETGE;
60269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  CCs[RTLIB::OLT_F32] = ISD::SETLT;
60369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  CCs[RTLIB::OLT_F64] = ISD::SETLT;
60469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  CCs[RTLIB::OLT_F128] = ISD::SETLT;
60569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  CCs[RTLIB::OLE_F32] = ISD::SETLE;
60669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  CCs[RTLIB::OLE_F64] = ISD::SETLE;
60769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  CCs[RTLIB::OLE_F128] = ISD::SETLE;
60869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  CCs[RTLIB::OGT_F32] = ISD::SETGT;
60969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  CCs[RTLIB::OGT_F64] = ISD::SETGT;
61069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  CCs[RTLIB::OGT_F128] = ISD::SETGT;
61169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  CCs[RTLIB::UO_F32] = ISD::SETNE;
61269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  CCs[RTLIB::UO_F64] = ISD::SETNE;
61369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  CCs[RTLIB::UO_F128] = ISD::SETNE;
61469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  CCs[RTLIB::O_F32] = ISD::SETEQ;
61569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  CCs[RTLIB::O_F64] = ISD::SETEQ;
61669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  CCs[RTLIB::O_F128] = ISD::SETEQ;
61769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer}
61869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
61969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// NOTE: The constructor takes ownership of TLOF.
62069e42dbd006c0afb732067ece7327988b1e24c01Benjamin KramerTargetLoweringBase::TargetLoweringBase(const TargetMachine &tm,
62169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer                                       const TargetLoweringObjectFile *tlof)
62269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  : TM(tm), TD(TM.getDataLayout()), TLOF(*tlof) {
62313bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  initActions();
62413bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling
62513bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  // Perform these initializations only once.
62613bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  IsLittleEndian = TD->isLittleEndian();
62713bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  PointerTy = MVT::getIntegerVT(8*TD->getPointerSize(0));
62813bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  MaxStoresPerMemset = MaxStoresPerMemcpy = MaxStoresPerMemmove = 8;
62913bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  MaxStoresPerMemsetOptSize = MaxStoresPerMemcpyOptSize
63013bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling    = MaxStoresPerMemmoveOptSize = 4;
63113bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  UseUnderscoreSetJmp = false;
63213bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  UseUnderscoreLongJmp = false;
63313bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  SelectIsExpensive = false;
63413bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  IntDivIsCheap = false;
63513bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  Pow2DivIsCheap = false;
63613bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  JumpIsExpensive = false;
63713bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  PredictableSelectIsExpensive = false;
63813bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  StackPointerRegisterToSaveRestore = 0;
63913bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  ExceptionPointerRegister = 0;
64013bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  ExceptionSelectorRegister = 0;
64113bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  BooleanContents = UndefinedBooleanContent;
64213bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  BooleanVectorContents = UndefinedBooleanContent;
64313bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  SchedPreferenceInfo = Sched::ILP;
64413bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  JumpBufSize = 0;
64513bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  JumpBufAlignment = 0;
64613bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  MinFunctionAlignment = 0;
64713bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  PrefFunctionAlignment = 0;
64813bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  PrefLoopAlignment = 0;
64913bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  MinStackArgumentAlignment = 1;
65013bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  ShouldFoldAtomicFences = false;
65113bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  InsertFencesForAtomic = false;
65213bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  SupportJumpTables = true;
65313bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  MinimumJumpTableEntries = 4;
65413bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling
65513bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  InitLibcallNames(LibcallRoutineNames, TM);
65613bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  InitCmpLibcallCCs(CmpLibcallCCs);
65713bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  InitLibcallCallingConvs(LibcallCallingConvs);
65813bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling}
65913bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling
66013bbe1f52e8d57151e2730db49094e1c62a4c793Bill WendlingTargetLoweringBase::~TargetLoweringBase() {
66113bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  delete &TLOF;
66213bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling}
66313bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling
66413bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendlingvoid TargetLoweringBase::initActions() {
66569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // All operations default to being supported.
66669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  memset(OpActions, 0, sizeof(OpActions));
66769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  memset(LoadExtActions, 0, sizeof(LoadExtActions));
66869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  memset(TruncStoreActions, 0, sizeof(TruncStoreActions));
66969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  memset(IndexedModeActions, 0, sizeof(IndexedModeActions));
67069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  memset(CondCodeActions, 0, sizeof(CondCodeActions));
67113bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  memset(RegClassForVT, 0,MVT::LAST_VALUETYPE*sizeof(TargetRegisterClass*));
67213bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling  memset(TargetDAGCombineArray, 0, array_lengthof(TargetDAGCombineArray));
67369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
67469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // Set default actions for various operations.
67569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  for (unsigned VT = 0; VT != (unsigned)MVT::LAST_VALUETYPE; ++VT) {
67669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    // Default all indexed load / store to expand.
67769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    for (unsigned IM = (unsigned)ISD::PRE_INC;
67869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer         IM != (unsigned)ISD::LAST_INDEXED_MODE; ++IM) {
67969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      setIndexedLoadAction(IM, (MVT::SimpleValueType)VT, Expand);
68069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      setIndexedStoreAction(IM, (MVT::SimpleValueType)VT, Expand);
68169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    }
68269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
68369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    // These operations default to expand.
68469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    setOperationAction(ISD::FGETSIGN, (MVT::SimpleValueType)VT, Expand);
68569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    setOperationAction(ISD::CONCAT_VECTORS, (MVT::SimpleValueType)VT, Expand);
68669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  }
68769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
68869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // Most targets ignore the @llvm.prefetch intrinsic.
68969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::PREFETCH, MVT::Other, Expand);
69069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
69169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // ConstantFP nodes default to expand.  Targets can either change this to
69269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // Legal, in which case all fp constants are legal, or use isFPImmLegal()
69369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // to optimize expansions for certain constants.
69469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::ConstantFP, MVT::f16, Expand);
69569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::ConstantFP, MVT::f32, Expand);
69669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::ConstantFP, MVT::f64, Expand);
69769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::ConstantFP, MVT::f80, Expand);
69869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::ConstantFP, MVT::f128, Expand);
69969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
70069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // These library functions default to expand.
70169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FLOG ,  MVT::f16, Expand);
70269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FLOG2,  MVT::f16, Expand);
70369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FLOG10, MVT::f16, Expand);
70469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FEXP ,  MVT::f16, Expand);
70569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FEXP2,  MVT::f16, Expand);
70669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FFLOOR, MVT::f16, Expand);
70769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FNEARBYINT, MVT::f16, Expand);
70869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FCEIL,  MVT::f16, Expand);
70969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FRINT,  MVT::f16, Expand);
71069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FTRUNC, MVT::f16, Expand);
71169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FLOG ,  MVT::f32, Expand);
71269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FLOG2,  MVT::f32, Expand);
71369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FLOG10, MVT::f32, Expand);
71469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FEXP ,  MVT::f32, Expand);
71569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FEXP2,  MVT::f32, Expand);
71669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FFLOOR, MVT::f32, Expand);
71769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FNEARBYINT, MVT::f32, Expand);
71869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FCEIL,  MVT::f32, Expand);
71969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FRINT,  MVT::f32, Expand);
72069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FTRUNC, MVT::f32, Expand);
72169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FLOG ,  MVT::f64, Expand);
72269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FLOG2,  MVT::f64, Expand);
72369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FLOG10, MVT::f64, Expand);
72469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FEXP ,  MVT::f64, Expand);
72569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FEXP2,  MVT::f64, Expand);
72669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FFLOOR, MVT::f64, Expand);
72769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FNEARBYINT, MVT::f64, Expand);
72869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FCEIL,  MVT::f64, Expand);
72969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FRINT,  MVT::f64, Expand);
73069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FTRUNC, MVT::f64, Expand);
73169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FLOG ,  MVT::f128, Expand);
73269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FLOG2,  MVT::f128, Expand);
73369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FLOG10, MVT::f128, Expand);
73469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FEXP ,  MVT::f128, Expand);
73569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FEXP2,  MVT::f128, Expand);
73669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FFLOOR, MVT::f128, Expand);
73769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FNEARBYINT, MVT::f128, Expand);
73869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FCEIL,  MVT::f128, Expand);
73969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FRINT,  MVT::f128, Expand);
74069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::FTRUNC, MVT::f128, Expand);
74169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
74269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // Default ISD::TRAP to expand (which turns it into abort).
74369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::TRAP, MVT::Other, Expand);
74469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
74569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // On most systems, DEBUGTRAP and TRAP have no difference. The "Expand"
74669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // here is to inform DAG Legalizer to replace DEBUGTRAP with TRAP.
74769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  //
74869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  setOperationAction(ISD::DEBUGTRAP, MVT::Other, Expand);
74969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer}
75069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
751a6b20ced765b67a85d9219d0c8547fc9c133e14fMichael LiaoMVT TargetLoweringBase::getScalarShiftAmountTy(EVT LHSTy) const {
75269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  return MVT::getIntegerVT(8*TD->getPointerSize(0));
75369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer}
75469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
755a6b20ced765b67a85d9219d0c8547fc9c133e14fMichael LiaoEVT TargetLoweringBase::getShiftAmountTy(EVT LHSTy) const {
756a6b20ced765b67a85d9219d0c8547fc9c133e14fMichael Liao  assert(LHSTy.isInteger() && "Shift amount is not an integer type!");
757a6b20ced765b67a85d9219d0c8547fc9c133e14fMichael Liao  if (LHSTy.isVector())
758a6b20ced765b67a85d9219d0c8547fc9c133e14fMichael Liao    return LHSTy;
759a6b20ced765b67a85d9219d0c8547fc9c133e14fMichael Liao  return getScalarShiftAmountTy(LHSTy);
760a6b20ced765b67a85d9219d0c8547fc9c133e14fMichael Liao}
761a6b20ced765b67a85d9219d0c8547fc9c133e14fMichael Liao
76269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// canOpTrap - Returns true if the operation can trap for the value type.
76369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// VT must be a legal type.
76469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramerbool TargetLoweringBase::canOpTrap(unsigned Op, EVT VT) const {
76569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  assert(isTypeLegal(VT));
76669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  switch (Op) {
76769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  default:
76869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    return false;
76969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case ISD::FDIV:
77069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case ISD::FREM:
77169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case ISD::SDIV:
77269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case ISD::UDIV:
77369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case ISD::SREM:
77469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case ISD::UREM:
77569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    return true;
77669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  }
77769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer}
77869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
77969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
78069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramerstatic unsigned getVectorTypeBreakdownMVT(MVT VT, MVT &IntermediateVT,
78169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer                                          unsigned &NumIntermediates,
78269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer                                          MVT &RegisterVT,
78369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer                                          TargetLoweringBase *TLI) {
78469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // Figure out the right, legal destination reg to copy into.
78569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  unsigned NumElts = VT.getVectorNumElements();
78669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  MVT EltTy = VT.getVectorElementType();
78769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
78869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  unsigned NumVectorRegs = 1;
78969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
79069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // FIXME: We don't support non-power-of-2-sized vectors for now.  Ideally we
79169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // could break down into LHS/RHS like LegalizeDAG does.
79269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  if (!isPowerOf2_32(NumElts)) {
79369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    NumVectorRegs = NumElts;
79469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    NumElts = 1;
79569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  }
79669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
79769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // Divide the input until we get to a supported size.  This will always
79869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // end with a scalar if the target doesn't support vectors.
79969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  while (NumElts > 1 && !TLI->isTypeLegal(MVT::getVectorVT(EltTy, NumElts))) {
80069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    NumElts >>= 1;
80169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    NumVectorRegs <<= 1;
80269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  }
80369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
80469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  NumIntermediates = NumVectorRegs;
80569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
80669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  MVT NewVT = MVT::getVectorVT(EltTy, NumElts);
80769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  if (!TLI->isTypeLegal(NewVT))
80869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    NewVT = EltTy;
80969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  IntermediateVT = NewVT;
81069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
81169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  unsigned NewVTSize = NewVT.getSizeInBits();
81269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
81369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // Convert sizes such as i33 to i64.
81469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  if (!isPowerOf2_32(NewVTSize))
81569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    NewVTSize = NextPowerOf2(NewVTSize);
81669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
81769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  MVT DestVT = TLI->getRegisterType(NewVT);
81869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  RegisterVT = DestVT;
81969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  if (EVT(DestVT).bitsLT(NewVT))    // Value is expanded, e.g. i64 -> i16.
82069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    return NumVectorRegs*(NewVTSize/DestVT.getSizeInBits());
82169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
82269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // Otherwise, promotion or legal types use the same number of registers as
82369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // the vector decimated to the appropriate level.
82469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  return NumVectorRegs;
82569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer}
82669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
82769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// isLegalRC - Return true if the value types that can be represented by the
82869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// specified register class are all legal.
82969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramerbool TargetLoweringBase::isLegalRC(const TargetRegisterClass *RC) const {
83069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  for (TargetRegisterClass::vt_iterator I = RC->vt_begin(), E = RC->vt_end();
83169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer       I != E; ++I) {
83269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (isTypeLegal(*I))
83369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return true;
83469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  }
83569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  return false;
83669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer}
83769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
83869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// findRepresentativeClass - Return the largest legal super-reg register class
83969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// of the register class for the specified type and its associated "cost".
84069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramerstd::pair<const TargetRegisterClass*, uint8_t>
84169e42dbd006c0afb732067ece7327988b1e24c01Benjamin KramerTargetLoweringBase::findRepresentativeClass(MVT VT) const {
84269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  const TargetRegisterInfo *TRI = getTargetMachine().getRegisterInfo();
84369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  const TargetRegisterClass *RC = RegClassForVT[VT.SimpleTy];
84469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  if (!RC)
84569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    return std::make_pair(RC, 0);
84669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
84769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // Compute the set of all super-register classes.
84869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  BitVector SuperRegRC(TRI->getNumRegClasses());
84969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  for (SuperRegClassIterator RCI(RC, TRI); RCI.isValid(); ++RCI)
85069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    SuperRegRC.setBitsInMask(RCI.getMask());
85169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
85269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // Find the first legal register class with the largest spill size.
85369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  const TargetRegisterClass *BestRC = RC;
85469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  for (int i = SuperRegRC.find_first(); i >= 0; i = SuperRegRC.find_next(i)) {
85569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    const TargetRegisterClass *SuperRC = TRI->getRegClass(i);
85669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    // We want the largest possible spill size.
85769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (SuperRC->getSize() <= BestRC->getSize())
85869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      continue;
85969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (!isLegalRC(SuperRC))
86069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      continue;
86169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    BestRC = SuperRC;
86269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  }
86369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  return std::make_pair(BestRC, 1);
86469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer}
86569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
86669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// computeRegisterProperties - Once all of the register classes are added,
86769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// this allows us to compute derived properties we expose.
86869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramervoid TargetLoweringBase::computeRegisterProperties() {
86969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  assert(MVT::LAST_VALUETYPE <= MVT::MAX_ALLOWED_VALUETYPE &&
87069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer         "Too many value types for ValueTypeActions to hold!");
87169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
87269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // Everything defaults to needing one register.
87369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  for (unsigned i = 0; i != MVT::LAST_VALUETYPE; ++i) {
87469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    NumRegistersForVT[i] = 1;
87569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    RegisterTypeForVT[i] = TransformToType[i] = (MVT::SimpleValueType)i;
87669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  }
87769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // ...except isVoid, which doesn't need any registers.
87869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  NumRegistersForVT[MVT::isVoid] = 0;
87969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
88069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // Find the largest integer register class.
88169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  unsigned LargestIntReg = MVT::LAST_INTEGER_VALUETYPE;
88269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  for (; RegClassForVT[LargestIntReg] == 0; --LargestIntReg)
88369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    assert(LargestIntReg != MVT::i1 && "No integer registers defined!");
88469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
88569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // Every integer value type larger than this largest register takes twice as
88669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // many registers to represent as the previous ValueType.
88769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  for (unsigned ExpandedReg = LargestIntReg + 1;
88869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer       ExpandedReg <= MVT::LAST_INTEGER_VALUETYPE; ++ExpandedReg) {
88969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    NumRegistersForVT[ExpandedReg] = 2*NumRegistersForVT[ExpandedReg-1];
89069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    RegisterTypeForVT[ExpandedReg] = (MVT::SimpleValueType)LargestIntReg;
89169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    TransformToType[ExpandedReg] = (MVT::SimpleValueType)(ExpandedReg - 1);
89269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    ValueTypeActions.setTypeAction((MVT::SimpleValueType)ExpandedReg,
89369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer                                   TypeExpandInteger);
89469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  }
89569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
89669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // Inspect all of the ValueType's smaller than the largest integer
89769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // register to see which ones need promotion.
89869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  unsigned LegalIntReg = LargestIntReg;
89969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  for (unsigned IntReg = LargestIntReg - 1;
90069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer       IntReg >= (unsigned)MVT::i1; --IntReg) {
90169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    MVT IVT = (MVT::SimpleValueType)IntReg;
90269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (isTypeLegal(IVT)) {
90369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      LegalIntReg = IntReg;
90469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    } else {
90569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      RegisterTypeForVT[IntReg] = TransformToType[IntReg] =
90669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer        (const MVT::SimpleValueType)LegalIntReg;
90769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      ValueTypeActions.setTypeAction(IVT, TypePromoteInteger);
90869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    }
90969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  }
91069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
91169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // ppcf128 type is really two f64's.
91269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  if (!isTypeLegal(MVT::ppcf128)) {
91369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    NumRegistersForVT[MVT::ppcf128] = 2*NumRegistersForVT[MVT::f64];
91469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    RegisterTypeForVT[MVT::ppcf128] = MVT::f64;
91569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    TransformToType[MVT::ppcf128] = MVT::f64;
91669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    ValueTypeActions.setTypeAction(MVT::ppcf128, TypeExpandFloat);
91769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  }
91869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
919c3c3810f514af7e08f84ef76b0c304ec264ee021Akira Hatanaka  // Decide how to handle f128. If the target does not have native f128 support,
920c3c3810f514af7e08f84ef76b0c304ec264ee021Akira Hatanaka  // expand it to i128 and we will be generating soft float library calls.
921c3c3810f514af7e08f84ef76b0c304ec264ee021Akira Hatanaka  if (!isTypeLegal(MVT::f128)) {
922c3c3810f514af7e08f84ef76b0c304ec264ee021Akira Hatanaka    NumRegistersForVT[MVT::f128] = NumRegistersForVT[MVT::i128];
923c3c3810f514af7e08f84ef76b0c304ec264ee021Akira Hatanaka    RegisterTypeForVT[MVT::f128] = RegisterTypeForVT[MVT::i128];
924c3c3810f514af7e08f84ef76b0c304ec264ee021Akira Hatanaka    TransformToType[MVT::f128] = MVT::i128;
925c3c3810f514af7e08f84ef76b0c304ec264ee021Akira Hatanaka    ValueTypeActions.setTypeAction(MVT::f128, TypeSoftenFloat);
926c3c3810f514af7e08f84ef76b0c304ec264ee021Akira Hatanaka  }
927c3c3810f514af7e08f84ef76b0c304ec264ee021Akira Hatanaka
92869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // Decide how to handle f64. If the target does not have native f64 support,
92969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // expand it to i64 and we will be generating soft float library calls.
93069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  if (!isTypeLegal(MVT::f64)) {
93169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    NumRegistersForVT[MVT::f64] = NumRegistersForVT[MVT::i64];
93269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    RegisterTypeForVT[MVT::f64] = RegisterTypeForVT[MVT::i64];
93369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    TransformToType[MVT::f64] = MVT::i64;
93469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    ValueTypeActions.setTypeAction(MVT::f64, TypeSoftenFloat);
93569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  }
93669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
93769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // Decide how to handle f32. If the target does not have native support for
93869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // f32, promote it to f64 if it is legal. Otherwise, expand it to i32.
93969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  if (!isTypeLegal(MVT::f32)) {
94069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (isTypeLegal(MVT::f64)) {
94169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      NumRegistersForVT[MVT::f32] = NumRegistersForVT[MVT::f64];
94269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      RegisterTypeForVT[MVT::f32] = RegisterTypeForVT[MVT::f64];
94369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      TransformToType[MVT::f32] = MVT::f64;
94469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      ValueTypeActions.setTypeAction(MVT::f32, TypePromoteInteger);
94569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    } else {
94669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      NumRegistersForVT[MVT::f32] = NumRegistersForVT[MVT::i32];
94769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      RegisterTypeForVT[MVT::f32] = RegisterTypeForVT[MVT::i32];
94869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      TransformToType[MVT::f32] = MVT::i32;
94969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      ValueTypeActions.setTypeAction(MVT::f32, TypeSoftenFloat);
95069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    }
95169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  }
95269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
95369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // Loop over all of the vector value types to see which need transformations.
95469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  for (unsigned i = MVT::FIRST_VECTOR_VALUETYPE;
95569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer       i <= (unsigned)MVT::LAST_VECTOR_VALUETYPE; ++i) {
95669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    MVT VT = (MVT::SimpleValueType)i;
95769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (isTypeLegal(VT)) continue;
95869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
95969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    // Determine if there is a legal wider type.  If so, we should promote to
96069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    // that wider vector type.
96169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    MVT EltVT = VT.getVectorElementType();
96269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    unsigned NElts = VT.getVectorNumElements();
96369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (NElts != 1 && !shouldSplitVectorElementType(EltVT)) {
96469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      bool IsLegalWiderType = false;
96569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      // First try to promote the elements of integer vectors. If no legal
96669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      // promotion was found, fallback to the widen-vector method.
96769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      for (unsigned nVT = i+1; nVT <= MVT::LAST_VECTOR_VALUETYPE; ++nVT) {
96869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer        MVT SVT = (MVT::SimpleValueType)nVT;
96969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer        // Promote vectors of integers to vectors with the same number
97069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer        // of elements, with a wider element type.
97169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer        if (SVT.getVectorElementType().getSizeInBits() > EltVT.getSizeInBits()
97269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer            && SVT.getVectorNumElements() == NElts &&
97369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer            isTypeLegal(SVT) && SVT.getScalarType().isInteger()) {
97469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer          TransformToType[i] = SVT;
97569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer          RegisterTypeForVT[i] = SVT;
97669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer          NumRegistersForVT[i] = 1;
97769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer          ValueTypeActions.setTypeAction(VT, TypePromoteInteger);
97869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer          IsLegalWiderType = true;
97969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer          break;
98069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer        }
98169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      }
98269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
98369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      if (IsLegalWiderType) continue;
98469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
98569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      // Try to widen the vector.
98669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      for (unsigned nVT = i+1; nVT <= MVT::LAST_VECTOR_VALUETYPE; ++nVT) {
98769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer        MVT SVT = (MVT::SimpleValueType)nVT;
98869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer        if (SVT.getVectorElementType() == EltVT &&
98969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer            SVT.getVectorNumElements() > NElts &&
99069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer            isTypeLegal(SVT)) {
99169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer          TransformToType[i] = SVT;
99269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer          RegisterTypeForVT[i] = SVT;
99369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer          NumRegistersForVT[i] = 1;
99469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer          ValueTypeActions.setTypeAction(VT, TypeWidenVector);
99569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer          IsLegalWiderType = true;
99669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer          break;
99769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer        }
99869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      }
99969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      if (IsLegalWiderType) continue;
100069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    }
100169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
100269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    MVT IntermediateVT;
100369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    MVT RegisterVT;
100469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    unsigned NumIntermediates;
100569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    NumRegistersForVT[i] =
100669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      getVectorTypeBreakdownMVT(VT, IntermediateVT, NumIntermediates,
100769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer                                RegisterVT, this);
100869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    RegisterTypeForVT[i] = RegisterVT;
100969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
101069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    MVT NVT = VT.getPow2VectorType();
101169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (NVT == VT) {
101269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      // Type is already a power of 2.  The default action is to split.
101369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      TransformToType[i] = MVT::Other;
101469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      unsigned NumElts = VT.getVectorNumElements();
101569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      ValueTypeActions.setTypeAction(VT,
101669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer            NumElts > 1 ? TypeSplitVector : TypeScalarizeVector);
101769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    } else {
101869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      TransformToType[i] = NVT;
101969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      ValueTypeActions.setTypeAction(VT, TypeWidenVector);
102069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    }
102169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  }
102269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
102369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // Determine the 'representative' register class for each value type.
102469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // An representative register class is the largest (meaning one which is
102569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // not a sub-register class / subreg register class) legal register class for
102669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // a group of value types. For example, on i386, i8, i16, and i32
102769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // representative would be GR32; while on x86_64 it's GR64.
102869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  for (unsigned i = 0; i != MVT::LAST_VALUETYPE; ++i) {
102969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    const TargetRegisterClass* RRC;
103069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    uint8_t Cost;
103169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    tie(RRC, Cost) =  findRepresentativeClass((MVT::SimpleValueType)i);
103269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    RepRegClassForVT[i] = RRC;
103369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    RepRegClassCostForVT[i] = Cost;
103469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  }
103569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer}
103669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
103769e42dbd006c0afb732067ece7327988b1e24c01Benjamin KramerEVT TargetLoweringBase::getSetCCResultType(EVT VT) const {
103869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  assert(!VT.isVector() && "No default SetCC type for vectors!");
103969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  return getPointerTy(0).SimpleTy;
104069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer}
104169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
104269e42dbd006c0afb732067ece7327988b1e24c01Benjamin KramerMVT::SimpleValueType TargetLoweringBase::getCmpLibcallReturnType() const {
104369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  return MVT::i32; // return the default value
104469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer}
104569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
104669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// getVectorTypeBreakdown - Vector types are broken down into some number of
104769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// legal first class types.  For example, MVT::v8f32 maps to 2 MVT::v4f32
104869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// with Altivec or SSE1, or 8 promoted MVT::f64 values with the X86 FP stack.
104969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// Similarly, MVT::v2i64 turns into 4 MVT::i32 values with both PPC and X86.
105069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer///
105169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// This method returns the number of registers needed, and the VT for each
105269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// register.  It also returns the VT and quantity of the intermediate values
105369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// before they are promoted/expanded.
105469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer///
105569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramerunsigned TargetLoweringBase::getVectorTypeBreakdown(LLVMContext &Context, EVT VT,
105669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer                                                EVT &IntermediateVT,
105769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer                                                unsigned &NumIntermediates,
105869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer                                                MVT &RegisterVT) const {
105969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  unsigned NumElts = VT.getVectorNumElements();
106069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
106169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // If there is a wider vector type with the same element type as this one,
106269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // or a promoted vector type that has the same number of elements which
106369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // are wider, then we should convert to that legal vector type.
106469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // This handles things like <2 x float> -> <4 x float> and
106569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // <4 x i1> -> <4 x i32>.
106669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  LegalizeTypeAction TA = getTypeAction(Context, VT);
106769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  if (NumElts != 1 && (TA == TypeWidenVector || TA == TypePromoteInteger)) {
106869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    EVT RegisterEVT = getTypeToTransformTo(Context, VT);
106969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (isTypeLegal(RegisterEVT)) {
107069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      IntermediateVT = RegisterEVT;
107169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      RegisterVT = RegisterEVT.getSimpleVT();
107269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      NumIntermediates = 1;
107369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return 1;
107469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    }
107569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  }
107669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
107769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // Figure out the right, legal destination reg to copy into.
107869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  EVT EltTy = VT.getVectorElementType();
107969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
108069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  unsigned NumVectorRegs = 1;
108169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
108269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // FIXME: We don't support non-power-of-2-sized vectors for now.  Ideally we
108369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // could break down into LHS/RHS like LegalizeDAG does.
108469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  if (!isPowerOf2_32(NumElts)) {
108569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    NumVectorRegs = NumElts;
108669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    NumElts = 1;
108769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  }
108869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
108969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // Divide the input until we get to a supported size.  This will always
109069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // end with a scalar if the target doesn't support vectors.
109169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  while (NumElts > 1 && !isTypeLegal(
109269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer                                   EVT::getVectorVT(Context, EltTy, NumElts))) {
109369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    NumElts >>= 1;
109469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    NumVectorRegs <<= 1;
109569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  }
109669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
109769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  NumIntermediates = NumVectorRegs;
109869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
109969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  EVT NewVT = EVT::getVectorVT(Context, EltTy, NumElts);
110069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  if (!isTypeLegal(NewVT))
110169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    NewVT = EltTy;
110269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  IntermediateVT = NewVT;
110369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
110469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  MVT DestVT = getRegisterType(Context, NewVT);
110569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  RegisterVT = DestVT;
110669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  unsigned NewVTSize = NewVT.getSizeInBits();
110769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
110869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // Convert sizes such as i33 to i64.
110969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  if (!isPowerOf2_32(NewVTSize))
111069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    NewVTSize = NextPowerOf2(NewVTSize);
111169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
111269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  if (EVT(DestVT).bitsLT(NewVT))   // Value is expanded, e.g. i64 -> i16.
111369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    return NumVectorRegs*(NewVTSize/DestVT.getSizeInBits());
111469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
111569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // Otherwise, promotion or legal types use the same number of registers as
111669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // the vector decimated to the appropriate level.
111769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  return NumVectorRegs;
111869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer}
111969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
112069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// Get the EVTs and ArgFlags collections that represent the legalized return
112169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// type of the given function.  This does not require a DAG or a return value,
112269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// and is suitable for use before any DAGs for the function are constructed.
112369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// TODO: Move this out of TargetLowering.cpp.
112469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramervoid llvm::GetReturnInfo(Type* ReturnType, AttributeSet attr,
112569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer                         SmallVectorImpl<ISD::OutputArg> &Outs,
112669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer                         const TargetLowering &TLI) {
112769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  SmallVector<EVT, 4> ValueVTs;
112869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  ComputeValueVTs(TLI, ReturnType, ValueVTs);
112969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  unsigned NumValues = ValueVTs.size();
113069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  if (NumValues == 0) return;
113169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
113269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  for (unsigned j = 0, f = NumValues; j != f; ++j) {
113369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    EVT VT = ValueVTs[j];
113469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    ISD::NodeType ExtendKind = ISD::ANY_EXTEND;
113569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
113669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (attr.hasAttribute(AttributeSet::ReturnIndex, Attribute::SExt))
113769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      ExtendKind = ISD::SIGN_EXTEND;
113869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    else if (attr.hasAttribute(AttributeSet::ReturnIndex, Attribute::ZExt))
113969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      ExtendKind = ISD::ZERO_EXTEND;
114069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
114169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    // FIXME: C calling convention requires the return type to be promoted to
114269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    // at least 32-bit. But this is not necessary for non-C calling
114369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    // conventions. The frontend should mark functions whose return values
114469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    // require promoting with signext or zeroext attributes.
114569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (ExtendKind != ISD::ANY_EXTEND && VT.isInteger()) {
114669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      MVT MinVT = TLI.getRegisterType(ReturnType->getContext(), MVT::i32);
114769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      if (VT.bitsLT(MinVT))
114869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer        VT = MinVT;
114969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    }
115069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
115169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    unsigned NumParts = TLI.getNumRegisters(ReturnType->getContext(), VT);
115269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    MVT PartVT = TLI.getRegisterType(ReturnType->getContext(), VT);
115369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
115469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    // 'inreg' on function refers to return value
115569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    ISD::ArgFlagsTy Flags = ISD::ArgFlagsTy();
115669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (attr.hasAttribute(AttributeSet::ReturnIndex, Attribute::InReg))
115769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      Flags.setInReg();
115869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
115969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    // Propagate extension type if any
116069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (attr.hasAttribute(AttributeSet::ReturnIndex, Attribute::SExt))
116169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      Flags.setSExt();
116269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    else if (attr.hasAttribute(AttributeSet::ReturnIndex, Attribute::ZExt))
116369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      Flags.setZExt();
116469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
116569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    for (unsigned i = 0; i < NumParts; ++i)
116669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      Outs.push_back(ISD::OutputArg(Flags, PartVT, /*isFixed=*/true, 0, 0));
116769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  }
116869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer}
116969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
117069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// getByValTypeAlignment - Return the desired alignment for ByVal aggregate
117169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// function arguments in the caller parameter area.  This is the actual
117269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// alignment, not its logarithm.
117369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramerunsigned TargetLoweringBase::getByValTypeAlignment(Type *Ty) const {
117469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  return TD->getCallFrameTypeAlignment(Ty);
117569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer}
117669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
117769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer//===----------------------------------------------------------------------===//
117869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer//  TargetTransformInfo Helpers
117969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer//===----------------------------------------------------------------------===//
118069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
118169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramerint TargetLoweringBase::InstructionOpcodeToISD(unsigned Opcode) const {
118269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  enum InstructionOpcodes {
118369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#define HANDLE_INST(NUM, OPCODE, CLASS) OPCODE = NUM,
118469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#define LAST_OTHER_INST(NUM) InstructionOpcodesCount = NUM
118569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/IR/Instruction.def"
118669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  };
118769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  switch (static_cast<InstructionOpcodes>(Opcode)) {
118869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case Ret:            return 0;
118969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case Br:             return 0;
119069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case Switch:         return 0;
119169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case IndirectBr:     return 0;
119269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case Invoke:         return 0;
119369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case Resume:         return 0;
119469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case Unreachable:    return 0;
119569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case Add:            return ISD::ADD;
119669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case FAdd:           return ISD::FADD;
119769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case Sub:            return ISD::SUB;
119869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case FSub:           return ISD::FSUB;
119969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case Mul:            return ISD::MUL;
120069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case FMul:           return ISD::FMUL;
120169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case UDiv:           return ISD::UDIV;
120269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case SDiv:           return ISD::UDIV;
120369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case FDiv:           return ISD::FDIV;
120469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case URem:           return ISD::UREM;
120569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case SRem:           return ISD::SREM;
120669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case FRem:           return ISD::FREM;
120769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case Shl:            return ISD::SHL;
120869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case LShr:           return ISD::SRL;
120969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case AShr:           return ISD::SRA;
121069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case And:            return ISD::AND;
121169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case Or:             return ISD::OR;
121269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case Xor:            return ISD::XOR;
121369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case Alloca:         return 0;
121469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case Load:           return ISD::LOAD;
121569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case Store:          return ISD::STORE;
121669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case GetElementPtr:  return 0;
121769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case Fence:          return 0;
121869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case AtomicCmpXchg:  return 0;
121969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case AtomicRMW:      return 0;
122069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case Trunc:          return ISD::TRUNCATE;
122169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case ZExt:           return ISD::ZERO_EXTEND;
122269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case SExt:           return ISD::SIGN_EXTEND;
122369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case FPToUI:         return ISD::FP_TO_UINT;
122469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case FPToSI:         return ISD::FP_TO_SINT;
122569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case UIToFP:         return ISD::UINT_TO_FP;
122669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case SIToFP:         return ISD::SINT_TO_FP;
122769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case FPTrunc:        return ISD::FP_ROUND;
122869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case FPExt:          return ISD::FP_EXTEND;
122969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case PtrToInt:       return ISD::BITCAST;
123069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case IntToPtr:       return ISD::BITCAST;
123169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case BitCast:        return ISD::BITCAST;
123269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case ICmp:           return ISD::SETCC;
123369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case FCmp:           return ISD::SETCC;
123469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case PHI:            return 0;
123569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case Call:           return 0;
123669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case Select:         return ISD::SELECT;
123769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case UserOp1:        return 0;
123869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case UserOp2:        return 0;
123969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case VAArg:          return 0;
124069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case ExtractElement: return ISD::EXTRACT_VECTOR_ELT;
124169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case InsertElement:  return ISD::INSERT_VECTOR_ELT;
124269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case ShuffleVector:  return ISD::VECTOR_SHUFFLE;
124369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case ExtractValue:   return ISD::MERGE_VALUES;
124469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case InsertValue:    return ISD::MERGE_VALUES;
124569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case LandingPad:     return 0;
124669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  }
124769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
124869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  llvm_unreachable("Unknown instruction type encountered!");
124969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer}
125069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
125169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramerstd::pair<unsigned, MVT>
125269e42dbd006c0afb732067ece7327988b1e24c01Benjamin KramerTargetLoweringBase::getTypeLegalizationCost(Type *Ty) const {
125369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  LLVMContext &C = Ty->getContext();
125469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  EVT MTy = getValueType(Ty);
125569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
125669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  unsigned Cost = 1;
125769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // We keep legalizing the type until we find a legal kind. We assume that
125869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // the only operation that costs anything is the split. After splitting
125969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // we need to handle two types.
126069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  while (true) {
126169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    LegalizeKind LK = getTypeConversion(C, MTy);
126269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
126369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (LK.first == TypeLegal)
126469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return std::make_pair(Cost, MTy.getSimpleVT());
126569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
126669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (LK.first == TypeSplitVector || LK.first == TypeExpandInteger)
126769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      Cost *= 2;
126869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
126969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    // Keep legalizing the type.
127069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    MTy = LK.second;
127169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  }
127269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer}
127369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
127469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer//===----------------------------------------------------------------------===//
127569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer//  Loop Strength Reduction hooks
127669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer//===----------------------------------------------------------------------===//
127769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
127869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// isLegalAddressingMode - Return true if the addressing mode represented
127969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// by AM is legal for this target, for a load/store of the specified type.
128069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramerbool TargetLoweringBase::isLegalAddressingMode(const AddrMode &AM,
128169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer                                           Type *Ty) const {
128269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // The default implementation of this implements a conservative RISCy, r+r and
128369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // r+i addr mode.
128469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
128569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // Allows a sign-extended 16-bit immediate field.
128669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  if (AM.BaseOffs <= -(1LL << 16) || AM.BaseOffs >= (1LL << 16)-1)
128769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    return false;
128869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
128969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // No global is ever allowed as a base.
129069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  if (AM.BaseGV)
129169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    return false;
129269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
129369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  // Only support r+r,
129469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  switch (AM.Scale) {
129569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case 0:  // "r+i" or just "i", depending on HasBaseReg.
129669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    break;
129769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case 1:
129869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (AM.HasBaseReg && AM.BaseOffs)  // "r+r+i" is not allowed.
129969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return false;
130069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    // Otherwise we have r+r or r+i.
130169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    break;
130269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  case 2:
130369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    if (AM.HasBaseReg || AM.BaseOffs)  // 2*r+r  or  2*r+i is not allowed.
130469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer      return false;
130569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    // Allow 2*r as r+r.
130669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer    break;
130769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  }
130869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer
130969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer  return true;
131069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer}
1311