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" 2136b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines#include "llvm/CodeGen/MachineInstrBuilder.h" 2269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/CodeGen/MachineJumpTableInfo.h" 2336b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines#include "llvm/CodeGen/StackMaps.h" 2469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/IR/DataLayout.h" 2569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/IR/DerivedTypes.h" 2669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/IR/GlobalVariable.h" 2736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines#include "llvm/IR/Mangler.h" 2869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/MC/MCAsmInfo.h" 2936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines#include "llvm/MC/MCContext.h" 3069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/MC/MCExpr.h" 3169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/Support/CommandLine.h" 3269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/Support/ErrorHandling.h" 3369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/Support/MathExtras.h" 3469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/Target/TargetLoweringObjectFile.h" 3569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/Target/TargetMachine.h" 3669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/Target/TargetRegisterInfo.h" 3737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines#include "llvm/Target/TargetSubtargetInfo.h" 3869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include <cctype> 3969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramerusing namespace llvm; 4069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 41cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainarstatic cl::opt<bool> JumpIsExpensiveOverride( 42cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar "jump-is-expensive", cl::init(false), 43cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar cl::desc("Do not create extra branches to split comparison logic."), 44cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar cl::Hidden); 45cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar 4669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// InitLibcallNames - Set default libcall names. 4769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// 48c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hinesstatic void InitLibcallNames(const char **Names, const Triple &TT) { 4969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SHL_I16] = "__ashlhi3"; 5069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SHL_I32] = "__ashlsi3"; 5169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SHL_I64] = "__ashldi3"; 5269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SHL_I128] = "__ashlti3"; 5369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SRL_I16] = "__lshrhi3"; 5469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SRL_I32] = "__lshrsi3"; 5569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SRL_I64] = "__lshrdi3"; 5669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SRL_I128] = "__lshrti3"; 5769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SRA_I16] = "__ashrhi3"; 5869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SRA_I32] = "__ashrsi3"; 5969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SRA_I64] = "__ashrdi3"; 6069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SRA_I128] = "__ashrti3"; 6169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::MUL_I8] = "__mulqi3"; 6269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::MUL_I16] = "__mulhi3"; 6369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::MUL_I32] = "__mulsi3"; 6469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::MUL_I64] = "__muldi3"; 6569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::MUL_I128] = "__multi3"; 6669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::MULO_I32] = "__mulosi4"; 6769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::MULO_I64] = "__mulodi4"; 6869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::MULO_I128] = "__muloti4"; 6969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SDIV_I8] = "__divqi3"; 7069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SDIV_I16] = "__divhi3"; 7169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SDIV_I32] = "__divsi3"; 7269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SDIV_I64] = "__divdi3"; 7369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SDIV_I128] = "__divti3"; 7469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UDIV_I8] = "__udivqi3"; 7569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UDIV_I16] = "__udivhi3"; 7669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UDIV_I32] = "__udivsi3"; 7769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UDIV_I64] = "__udivdi3"; 7869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UDIV_I128] = "__udivti3"; 7969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SREM_I8] = "__modqi3"; 8069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SREM_I16] = "__modhi3"; 8169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SREM_I32] = "__modsi3"; 8269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SREM_I64] = "__moddi3"; 8369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SREM_I128] = "__modti3"; 8469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UREM_I8] = "__umodqi3"; 8569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UREM_I16] = "__umodhi3"; 8669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UREM_I32] = "__umodsi3"; 8769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UREM_I64] = "__umoddi3"; 8869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UREM_I128] = "__umodti3"; 8969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 9069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // These are generally not available. 91dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines Names[RTLIB::SDIVREM_I8] = nullptr; 92dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines Names[RTLIB::SDIVREM_I16] = nullptr; 93dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines Names[RTLIB::SDIVREM_I32] = nullptr; 94dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines Names[RTLIB::SDIVREM_I64] = nullptr; 95dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines Names[RTLIB::SDIVREM_I128] = nullptr; 96dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines Names[RTLIB::UDIVREM_I8] = nullptr; 97dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines Names[RTLIB::UDIVREM_I16] = nullptr; 98dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines Names[RTLIB::UDIVREM_I32] = nullptr; 99dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines Names[RTLIB::UDIVREM_I64] = nullptr; 100dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines Names[RTLIB::UDIVREM_I128] = nullptr; 10169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 10269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::NEG_I32] = "__negsi2"; 10369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::NEG_I64] = "__negdi2"; 10469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::ADD_F32] = "__addsf3"; 10569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::ADD_F64] = "__adddf3"; 10669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::ADD_F80] = "__addxf3"; 10769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::ADD_F128] = "__addtf3"; 10869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::ADD_PPCF128] = "__gcc_qadd"; 10969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SUB_F32] = "__subsf3"; 11069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SUB_F64] = "__subdf3"; 11169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SUB_F80] = "__subxf3"; 11269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SUB_F128] = "__subtf3"; 11369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SUB_PPCF128] = "__gcc_qsub"; 11469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::MUL_F32] = "__mulsf3"; 11569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::MUL_F64] = "__muldf3"; 11669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::MUL_F80] = "__mulxf3"; 11769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::MUL_F128] = "__multf3"; 11869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::MUL_PPCF128] = "__gcc_qmul"; 11969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::DIV_F32] = "__divsf3"; 12069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::DIV_F64] = "__divdf3"; 12169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::DIV_F80] = "__divxf3"; 12269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::DIV_F128] = "__divtf3"; 12369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::DIV_PPCF128] = "__gcc_qdiv"; 12469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::REM_F32] = "fmodf"; 12569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::REM_F64] = "fmod"; 12669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::REM_F80] = "fmodl"; 12769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::REM_F128] = "fmodl"; 12869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::REM_PPCF128] = "fmodl"; 12969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FMA_F32] = "fmaf"; 13069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FMA_F64] = "fma"; 13169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FMA_F80] = "fmal"; 13269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FMA_F128] = "fmal"; 13369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FMA_PPCF128] = "fmal"; 13469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::POWI_F32] = "__powisf2"; 13569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::POWI_F64] = "__powidf2"; 13669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::POWI_F80] = "__powixf2"; 13769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::POWI_F128] = "__powitf2"; 13869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::POWI_PPCF128] = "__powitf2"; 13969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SQRT_F32] = "sqrtf"; 14069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SQRT_F64] = "sqrt"; 14169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SQRT_F80] = "sqrtl"; 14269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SQRT_F128] = "sqrtl"; 14369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SQRT_PPCF128] = "sqrtl"; 14469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::LOG_F32] = "logf"; 14569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::LOG_F64] = "log"; 14669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::LOG_F80] = "logl"; 14769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::LOG_F128] = "logl"; 14869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::LOG_PPCF128] = "logl"; 14969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::LOG2_F32] = "log2f"; 15069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::LOG2_F64] = "log2"; 15169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::LOG2_F80] = "log2l"; 15269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::LOG2_F128] = "log2l"; 15369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::LOG2_PPCF128] = "log2l"; 15469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::LOG10_F32] = "log10f"; 15569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::LOG10_F64] = "log10"; 15669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::LOG10_F80] = "log10l"; 15769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::LOG10_F128] = "log10l"; 15869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::LOG10_PPCF128] = "log10l"; 15969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::EXP_F32] = "expf"; 16069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::EXP_F64] = "exp"; 16169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::EXP_F80] = "expl"; 16269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::EXP_F128] = "expl"; 16369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::EXP_PPCF128] = "expl"; 16469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::EXP2_F32] = "exp2f"; 16569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::EXP2_F64] = "exp2"; 16669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::EXP2_F80] = "exp2l"; 16769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::EXP2_F128] = "exp2l"; 16869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::EXP2_PPCF128] = "exp2l"; 16969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SIN_F32] = "sinf"; 17069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SIN_F64] = "sin"; 17169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SIN_F80] = "sinl"; 17269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SIN_F128] = "sinl"; 17369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SIN_PPCF128] = "sinl"; 17469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::COS_F32] = "cosf"; 17569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::COS_F64] = "cos"; 17669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::COS_F80] = "cosl"; 17769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::COS_F128] = "cosl"; 17869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::COS_PPCF128] = "cosl"; 17969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::POW_F32] = "powf"; 18069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::POW_F64] = "pow"; 18169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::POW_F80] = "powl"; 18269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::POW_F128] = "powl"; 18369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::POW_PPCF128] = "powl"; 18469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::CEIL_F32] = "ceilf"; 18569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::CEIL_F64] = "ceil"; 18669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::CEIL_F80] = "ceill"; 18769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::CEIL_F128] = "ceill"; 18869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::CEIL_PPCF128] = "ceill"; 18969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::TRUNC_F32] = "truncf"; 19069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::TRUNC_F64] = "trunc"; 19169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::TRUNC_F80] = "truncl"; 19269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::TRUNC_F128] = "truncl"; 19369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::TRUNC_PPCF128] = "truncl"; 19469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::RINT_F32] = "rintf"; 19569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::RINT_F64] = "rint"; 19669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::RINT_F80] = "rintl"; 19769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::RINT_F128] = "rintl"; 19869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::RINT_PPCF128] = "rintl"; 19969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::NEARBYINT_F32] = "nearbyintf"; 20069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::NEARBYINT_F64] = "nearbyint"; 20169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::NEARBYINT_F80] = "nearbyintl"; 20269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::NEARBYINT_F128] = "nearbyintl"; 20369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::NEARBYINT_PPCF128] = "nearbyintl"; 20441418d17cced656f91038b2482bc9d173b4974b0Hal Finkel Names[RTLIB::ROUND_F32] = "roundf"; 20541418d17cced656f91038b2482bc9d173b4974b0Hal Finkel Names[RTLIB::ROUND_F64] = "round"; 20641418d17cced656f91038b2482bc9d173b4974b0Hal Finkel Names[RTLIB::ROUND_F80] = "roundl"; 20741418d17cced656f91038b2482bc9d173b4974b0Hal Finkel Names[RTLIB::ROUND_F128] = "roundl"; 20841418d17cced656f91038b2482bc9d173b4974b0Hal Finkel Names[RTLIB::ROUND_PPCF128] = "roundl"; 20969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FLOOR_F32] = "floorf"; 21069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FLOOR_F64] = "floor"; 21169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FLOOR_F80] = "floorl"; 21269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FLOOR_F128] = "floorl"; 21369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FLOOR_PPCF128] = "floorl"; 21437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines Names[RTLIB::FMIN_F32] = "fminf"; 21537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines Names[RTLIB::FMIN_F64] = "fmin"; 21637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines Names[RTLIB::FMIN_F80] = "fminl"; 21737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines Names[RTLIB::FMIN_F128] = "fminl"; 21837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines Names[RTLIB::FMIN_PPCF128] = "fminl"; 21937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines Names[RTLIB::FMAX_F32] = "fmaxf"; 22037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines Names[RTLIB::FMAX_F64] = "fmax"; 22137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines Names[RTLIB::FMAX_F80] = "fmaxl"; 22237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines Names[RTLIB::FMAX_F128] = "fmaxl"; 22337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines Names[RTLIB::FMAX_PPCF128] = "fmaxl"; 22436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines Names[RTLIB::ROUND_F32] = "roundf"; 22536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines Names[RTLIB::ROUND_F64] = "round"; 22636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines Names[RTLIB::ROUND_F80] = "roundl"; 22736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines Names[RTLIB::ROUND_F128] = "roundl"; 22836b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines Names[RTLIB::ROUND_PPCF128] = "roundl"; 22969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::COPYSIGN_F32] = "copysignf"; 23069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::COPYSIGN_F64] = "copysign"; 23169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::COPYSIGN_F80] = "copysignl"; 23269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::COPYSIGN_F128] = "copysignl"; 23369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::COPYSIGN_PPCF128] = "copysignl"; 23469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPEXT_F64_F128] = "__extenddftf2"; 23569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPEXT_F32_F128] = "__extendsftf2"; 23669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPEXT_F32_F64] = "__extendsfdf2"; 23769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPEXT_F16_F32] = "__gnu_h2f_ieee"; 23869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPROUND_F32_F16] = "__gnu_f2h_ieee"; 23937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines Names[RTLIB::FPROUND_F64_F16] = "__truncdfhf2"; 24037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines Names[RTLIB::FPROUND_F80_F16] = "__truncxfhf2"; 24137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines Names[RTLIB::FPROUND_F128_F16] = "__trunctfhf2"; 24237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines Names[RTLIB::FPROUND_PPCF128_F16] = "__trunctfhf2"; 24369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPROUND_F64_F32] = "__truncdfsf2"; 24469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPROUND_F80_F32] = "__truncxfsf2"; 24569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPROUND_F128_F32] = "__trunctfsf2"; 24669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPROUND_PPCF128_F32] = "__trunctfsf2"; 24769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPROUND_F80_F64] = "__truncxfdf2"; 24869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPROUND_F128_F64] = "__trunctfdf2"; 24969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPROUND_PPCF128_F64] = "__trunctfdf2"; 25069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOSINT_F32_I32] = "__fixsfsi"; 25169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOSINT_F32_I64] = "__fixsfdi"; 25269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOSINT_F32_I128] = "__fixsfti"; 25369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOSINT_F64_I32] = "__fixdfsi"; 25469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOSINT_F64_I64] = "__fixdfdi"; 25569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOSINT_F64_I128] = "__fixdfti"; 25669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOSINT_F80_I32] = "__fixxfsi"; 25769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOSINT_F80_I64] = "__fixxfdi"; 25869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOSINT_F80_I128] = "__fixxfti"; 25969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOSINT_F128_I32] = "__fixtfsi"; 26069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOSINT_F128_I64] = "__fixtfdi"; 26169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOSINT_F128_I128] = "__fixtfti"; 26269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOSINT_PPCF128_I32] = "__fixtfsi"; 26369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOSINT_PPCF128_I64] = "__fixtfdi"; 26469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOSINT_PPCF128_I128] = "__fixtfti"; 26569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOUINT_F32_I32] = "__fixunssfsi"; 26669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOUINT_F32_I64] = "__fixunssfdi"; 26769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOUINT_F32_I128] = "__fixunssfti"; 26869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOUINT_F64_I32] = "__fixunsdfsi"; 26969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOUINT_F64_I64] = "__fixunsdfdi"; 27069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOUINT_F64_I128] = "__fixunsdfti"; 27169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOUINT_F80_I32] = "__fixunsxfsi"; 27269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOUINT_F80_I64] = "__fixunsxfdi"; 27369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOUINT_F80_I128] = "__fixunsxfti"; 27469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOUINT_F128_I32] = "__fixunstfsi"; 27569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOUINT_F128_I64] = "__fixunstfdi"; 27669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOUINT_F128_I128] = "__fixunstfti"; 27769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOUINT_PPCF128_I32] = "__fixunstfsi"; 27869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOUINT_PPCF128_I64] = "__fixunstfdi"; 27969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::FPTOUINT_PPCF128_I128] = "__fixunstfti"; 28069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SINTTOFP_I32_F32] = "__floatsisf"; 28169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SINTTOFP_I32_F64] = "__floatsidf"; 28269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SINTTOFP_I32_F80] = "__floatsixf"; 28369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SINTTOFP_I32_F128] = "__floatsitf"; 28469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SINTTOFP_I32_PPCF128] = "__floatsitf"; 28569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SINTTOFP_I64_F32] = "__floatdisf"; 28669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SINTTOFP_I64_F64] = "__floatdidf"; 28769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SINTTOFP_I64_F80] = "__floatdixf"; 28869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SINTTOFP_I64_F128] = "__floatditf"; 28969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SINTTOFP_I64_PPCF128] = "__floatditf"; 29069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SINTTOFP_I128_F32] = "__floattisf"; 29169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SINTTOFP_I128_F64] = "__floattidf"; 29269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SINTTOFP_I128_F80] = "__floattixf"; 29369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SINTTOFP_I128_F128] = "__floattitf"; 29469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SINTTOFP_I128_PPCF128] = "__floattitf"; 29569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UINTTOFP_I32_F32] = "__floatunsisf"; 29669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UINTTOFP_I32_F64] = "__floatunsidf"; 29769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UINTTOFP_I32_F80] = "__floatunsixf"; 29869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UINTTOFP_I32_F128] = "__floatunsitf"; 29969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UINTTOFP_I32_PPCF128] = "__floatunsitf"; 30069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UINTTOFP_I64_F32] = "__floatundisf"; 30169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UINTTOFP_I64_F64] = "__floatundidf"; 30269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UINTTOFP_I64_F80] = "__floatundixf"; 30369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UINTTOFP_I64_F128] = "__floatunditf"; 30469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UINTTOFP_I64_PPCF128] = "__floatunditf"; 30569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UINTTOFP_I128_F32] = "__floatuntisf"; 30669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UINTTOFP_I128_F64] = "__floatuntidf"; 30769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UINTTOFP_I128_F80] = "__floatuntixf"; 30869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UINTTOFP_I128_F128] = "__floatuntitf"; 30969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UINTTOFP_I128_PPCF128] = "__floatuntitf"; 31069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::OEQ_F32] = "__eqsf2"; 31169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::OEQ_F64] = "__eqdf2"; 31269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::OEQ_F128] = "__eqtf2"; 31369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UNE_F32] = "__nesf2"; 31469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UNE_F64] = "__nedf2"; 31569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UNE_F128] = "__netf2"; 31669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::OGE_F32] = "__gesf2"; 31769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::OGE_F64] = "__gedf2"; 31869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::OGE_F128] = "__getf2"; 31969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::OLT_F32] = "__ltsf2"; 32069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::OLT_F64] = "__ltdf2"; 32169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::OLT_F128] = "__lttf2"; 32269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::OLE_F32] = "__lesf2"; 32369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::OLE_F64] = "__ledf2"; 32469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::OLE_F128] = "__letf2"; 32569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::OGT_F32] = "__gtsf2"; 32669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::OGT_F64] = "__gtdf2"; 32769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::OGT_F128] = "__gttf2"; 32869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UO_F32] = "__unordsf2"; 32969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UO_F64] = "__unorddf2"; 33069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UO_F128] = "__unordtf2"; 33169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::O_F32] = "__unordsf2"; 33269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::O_F64] = "__unorddf2"; 33369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::O_F128] = "__unordtf2"; 33469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::MEMCPY] = "memcpy"; 33569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::MEMMOVE] = "memmove"; 33669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::MEMSET] = "memset"; 33769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::UNWIND_RESUME] = "_Unwind_Resume"; 33869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_VAL_COMPARE_AND_SWAP_1] = "__sync_val_compare_and_swap_1"; 33969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_VAL_COMPARE_AND_SWAP_2] = "__sync_val_compare_and_swap_2"; 34069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_VAL_COMPARE_AND_SWAP_4] = "__sync_val_compare_and_swap_4"; 34169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_VAL_COMPARE_AND_SWAP_8] = "__sync_val_compare_and_swap_8"; 342641bea117d2f5e68c11156b9eea1c9270825dfb9David Majnemer Names[RTLIB::SYNC_VAL_COMPARE_AND_SWAP_16] = "__sync_val_compare_and_swap_16"; 34369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_LOCK_TEST_AND_SET_1] = "__sync_lock_test_and_set_1"; 34469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_LOCK_TEST_AND_SET_2] = "__sync_lock_test_and_set_2"; 34569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_LOCK_TEST_AND_SET_4] = "__sync_lock_test_and_set_4"; 34669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_LOCK_TEST_AND_SET_8] = "__sync_lock_test_and_set_8"; 347641bea117d2f5e68c11156b9eea1c9270825dfb9David Majnemer Names[RTLIB::SYNC_LOCK_TEST_AND_SET_16] = "__sync_lock_test_and_set_16"; 34869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_FETCH_AND_ADD_1] = "__sync_fetch_and_add_1"; 34969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_FETCH_AND_ADD_2] = "__sync_fetch_and_add_2"; 35069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_FETCH_AND_ADD_4] = "__sync_fetch_and_add_4"; 35169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_FETCH_AND_ADD_8] = "__sync_fetch_and_add_8"; 352641bea117d2f5e68c11156b9eea1c9270825dfb9David Majnemer Names[RTLIB::SYNC_FETCH_AND_ADD_16] = "__sync_fetch_and_add_16"; 35369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_FETCH_AND_SUB_1] = "__sync_fetch_and_sub_1"; 35469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_FETCH_AND_SUB_2] = "__sync_fetch_and_sub_2"; 35569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_FETCH_AND_SUB_4] = "__sync_fetch_and_sub_4"; 35669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_FETCH_AND_SUB_8] = "__sync_fetch_and_sub_8"; 357641bea117d2f5e68c11156b9eea1c9270825dfb9David Majnemer Names[RTLIB::SYNC_FETCH_AND_SUB_16] = "__sync_fetch_and_sub_16"; 35869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_FETCH_AND_AND_1] = "__sync_fetch_and_and_1"; 35969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_FETCH_AND_AND_2] = "__sync_fetch_and_and_2"; 36069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_FETCH_AND_AND_4] = "__sync_fetch_and_and_4"; 36169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_FETCH_AND_AND_8] = "__sync_fetch_and_and_8"; 362641bea117d2f5e68c11156b9eea1c9270825dfb9David Majnemer Names[RTLIB::SYNC_FETCH_AND_AND_16] = "__sync_fetch_and_and_16"; 36369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_FETCH_AND_OR_1] = "__sync_fetch_and_or_1"; 36469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_FETCH_AND_OR_2] = "__sync_fetch_and_or_2"; 36569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_FETCH_AND_OR_4] = "__sync_fetch_and_or_4"; 36669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_FETCH_AND_OR_8] = "__sync_fetch_and_or_8"; 367641bea117d2f5e68c11156b9eea1c9270825dfb9David Majnemer Names[RTLIB::SYNC_FETCH_AND_OR_16] = "__sync_fetch_and_or_16"; 36869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_FETCH_AND_XOR_1] = "__sync_fetch_and_xor_1"; 36969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_FETCH_AND_XOR_2] = "__sync_fetch_and_xor_2"; 37069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_FETCH_AND_XOR_4] = "__sync_fetch_and_xor_4"; 37169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_FETCH_AND_XOR_8] = "__sync_fetch_and_xor_8"; 372641bea117d2f5e68c11156b9eea1c9270825dfb9David Majnemer Names[RTLIB::SYNC_FETCH_AND_XOR_16] = "__sync_fetch_and_xor_16"; 37369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_FETCH_AND_NAND_1] = "__sync_fetch_and_nand_1"; 37469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_FETCH_AND_NAND_2] = "__sync_fetch_and_nand_2"; 37569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_FETCH_AND_NAND_4] = "__sync_fetch_and_nand_4"; 37669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Names[RTLIB::SYNC_FETCH_AND_NAND_8] = "__sync_fetch_and_nand_8"; 377641bea117d2f5e68c11156b9eea1c9270825dfb9David Majnemer Names[RTLIB::SYNC_FETCH_AND_NAND_16] = "__sync_fetch_and_nand_16"; 3785a42ae81f742aaab826b7a72cb0a9a7e5a957a07Tim Northover Names[RTLIB::SYNC_FETCH_AND_MAX_1] = "__sync_fetch_and_max_1"; 3795a42ae81f742aaab826b7a72cb0a9a7e5a957a07Tim Northover Names[RTLIB::SYNC_FETCH_AND_MAX_2] = "__sync_fetch_and_max_2"; 3805a42ae81f742aaab826b7a72cb0a9a7e5a957a07Tim Northover Names[RTLIB::SYNC_FETCH_AND_MAX_4] = "__sync_fetch_and_max_4"; 3815a42ae81f742aaab826b7a72cb0a9a7e5a957a07Tim Northover Names[RTLIB::SYNC_FETCH_AND_MAX_8] = "__sync_fetch_and_max_8"; 3825a42ae81f742aaab826b7a72cb0a9a7e5a957a07Tim Northover Names[RTLIB::SYNC_FETCH_AND_MAX_16] = "__sync_fetch_and_max_16"; 3835a42ae81f742aaab826b7a72cb0a9a7e5a957a07Tim Northover Names[RTLIB::SYNC_FETCH_AND_UMAX_1] = "__sync_fetch_and_umax_1"; 3845a42ae81f742aaab826b7a72cb0a9a7e5a957a07Tim Northover Names[RTLIB::SYNC_FETCH_AND_UMAX_2] = "__sync_fetch_and_umax_2"; 3855a42ae81f742aaab826b7a72cb0a9a7e5a957a07Tim Northover Names[RTLIB::SYNC_FETCH_AND_UMAX_4] = "__sync_fetch_and_umax_4"; 3865a42ae81f742aaab826b7a72cb0a9a7e5a957a07Tim Northover Names[RTLIB::SYNC_FETCH_AND_UMAX_8] = "__sync_fetch_and_umax_8"; 3875a42ae81f742aaab826b7a72cb0a9a7e5a957a07Tim Northover Names[RTLIB::SYNC_FETCH_AND_UMAX_16] = "__sync_fetch_and_umax_16"; 3885a42ae81f742aaab826b7a72cb0a9a7e5a957a07Tim Northover Names[RTLIB::SYNC_FETCH_AND_MIN_1] = "__sync_fetch_and_min_1"; 3895a42ae81f742aaab826b7a72cb0a9a7e5a957a07Tim Northover Names[RTLIB::SYNC_FETCH_AND_MIN_2] = "__sync_fetch_and_min_2"; 3905a42ae81f742aaab826b7a72cb0a9a7e5a957a07Tim Northover Names[RTLIB::SYNC_FETCH_AND_MIN_4] = "__sync_fetch_and_min_4"; 3915a42ae81f742aaab826b7a72cb0a9a7e5a957a07Tim Northover Names[RTLIB::SYNC_FETCH_AND_MIN_8] = "__sync_fetch_and_min_8"; 3925a42ae81f742aaab826b7a72cb0a9a7e5a957a07Tim Northover Names[RTLIB::SYNC_FETCH_AND_MIN_16] = "__sync_fetch_and_min_16"; 3935a42ae81f742aaab826b7a72cb0a9a7e5a957a07Tim Northover Names[RTLIB::SYNC_FETCH_AND_UMIN_1] = "__sync_fetch_and_umin_1"; 3945a42ae81f742aaab826b7a72cb0a9a7e5a957a07Tim Northover Names[RTLIB::SYNC_FETCH_AND_UMIN_2] = "__sync_fetch_and_umin_2"; 3955a42ae81f742aaab826b7a72cb0a9a7e5a957a07Tim Northover Names[RTLIB::SYNC_FETCH_AND_UMIN_4] = "__sync_fetch_and_umin_4"; 3965a42ae81f742aaab826b7a72cb0a9a7e5a957a07Tim Northover Names[RTLIB::SYNC_FETCH_AND_UMIN_8] = "__sync_fetch_and_umin_8"; 3975a42ae81f742aaab826b7a72cb0a9a7e5a957a07Tim Northover Names[RTLIB::SYNC_FETCH_AND_UMIN_16] = "__sync_fetch_and_umin_16"; 3988688a58c53b46d2dda9bf50dafd5195790a7ed58Evan Cheng 399c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines if (TT.getEnvironment() == Triple::GNU) { 40086cdbc9c29a572d422815f55fd89ff7510d1e3e8Paul Redmond Names[RTLIB::SINCOS_F32] = "sincosf"; 40186cdbc9c29a572d422815f55fd89ff7510d1e3e8Paul Redmond Names[RTLIB::SINCOS_F64] = "sincos"; 40286cdbc9c29a572d422815f55fd89ff7510d1e3e8Paul Redmond Names[RTLIB::SINCOS_F80] = "sincosl"; 40386cdbc9c29a572d422815f55fd89ff7510d1e3e8Paul Redmond Names[RTLIB::SINCOS_F128] = "sincosl"; 40486cdbc9c29a572d422815f55fd89ff7510d1e3e8Paul Redmond Names[RTLIB::SINCOS_PPCF128] = "sincosl"; 40586cdbc9c29a572d422815f55fd89ff7510d1e3e8Paul Redmond } else { 40686cdbc9c29a572d422815f55fd89ff7510d1e3e8Paul Redmond // These are generally not available. 407dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines Names[RTLIB::SINCOS_F32] = nullptr; 408dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines Names[RTLIB::SINCOS_F64] = nullptr; 409dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines Names[RTLIB::SINCOS_F80] = nullptr; 410dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines Names[RTLIB::SINCOS_F128] = nullptr; 411dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines Names[RTLIB::SINCOS_PPCF128] = nullptr; 41286cdbc9c29a572d422815f55fd89ff7510d1e3e8Paul Redmond } 41315b2782ccf141930cc98507a1cb1d501fbfd4000Michael Gottesman 414ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines if (!TT.isOSOpenBSD()) { 41515b2782ccf141930cc98507a1cb1d501fbfd4000Michael Gottesman Names[RTLIB::STACKPROTECTOR_CHECK_FAIL] = "__stack_chk_fail"; 41615b2782ccf141930cc98507a1cb1d501fbfd4000Michael Gottesman } else { 41715b2782ccf141930cc98507a1cb1d501fbfd4000Michael Gottesman // These are generally not available. 418dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines Names[RTLIB::STACKPROTECTOR_CHECK_FAIL] = nullptr; 41915b2782ccf141930cc98507a1cb1d501fbfd4000Michael Gottesman } 4206948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar 4216948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar // For f16/f32 conversions, Darwin uses the standard naming scheme, instead 4226948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar // of the gnueabi-style __gnu_*_ieee. 4236948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar // FIXME: What about other targets? 4246948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar if (TT.isOSDarwin()) { 4256948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar Names[RTLIB::FPEXT_F16_F32] = "__extendhfsf2"; 4266948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar Names[RTLIB::FPROUND_F32_F16] = "__truncsfhf2"; 4276948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar } 42869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer} 42969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 43069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// InitLibcallCallingConvs - Set default libcall CallingConvs. 43169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// 43269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramerstatic void InitLibcallCallingConvs(CallingConv::ID *CCs) { 43369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer for (int i = 0; i < RTLIB::UNKNOWN_LIBCALL; ++i) { 43469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer CCs[i] = CallingConv::C; 43569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 43669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer} 43769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 43869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// getFPEXT - Return the FPEXT_*_* value for the given types, or 43969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// UNKNOWN_LIBCALL if there is none. 44069e42dbd006c0afb732067ece7327988b1e24c01Benjamin KramerRTLIB::Libcall RTLIB::getFPEXT(EVT OpVT, EVT RetVT) { 44137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines if (OpVT == MVT::f16) { 44237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines if (RetVT == MVT::f32) 44337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines return FPEXT_F16_F32; 44437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines } else if (OpVT == MVT::f32) { 44569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::f64) 44669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPEXT_F32_F64; 44769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::f128) 44869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPEXT_F32_F128; 44969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } else if (OpVT == MVT::f64) { 45069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::f128) 45169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPEXT_F64_F128; 45269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 45369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 45469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return UNKNOWN_LIBCALL; 45569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer} 45669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 45769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// getFPROUND - Return the FPROUND_*_* value for the given types, or 45869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// UNKNOWN_LIBCALL if there is none. 45969e42dbd006c0afb732067ece7327988b1e24c01Benjamin KramerRTLIB::Libcall RTLIB::getFPROUND(EVT OpVT, EVT RetVT) { 46037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines if (RetVT == MVT::f16) { 46137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines if (OpVT == MVT::f32) 46237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines return FPROUND_F32_F16; 46337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines if (OpVT == MVT::f64) 46437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines return FPROUND_F64_F16; 46537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines if (OpVT == MVT::f80) 46637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines return FPROUND_F80_F16; 46737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines if (OpVT == MVT::f128) 46837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines return FPROUND_F128_F16; 46937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines if (OpVT == MVT::ppcf128) 47037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines return FPROUND_PPCF128_F16; 47137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines } else if (RetVT == MVT::f32) { 47269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (OpVT == MVT::f64) 47369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPROUND_F64_F32; 47469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (OpVT == MVT::f80) 47569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPROUND_F80_F32; 47669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (OpVT == MVT::f128) 47769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPROUND_F128_F32; 47869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (OpVT == MVT::ppcf128) 47969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPROUND_PPCF128_F32; 48069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } else if (RetVT == MVT::f64) { 48169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (OpVT == MVT::f80) 48269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPROUND_F80_F64; 48369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (OpVT == MVT::f128) 48469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPROUND_F128_F64; 48569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (OpVT == MVT::ppcf128) 48669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPROUND_PPCF128_F64; 48769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 48869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 48969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return UNKNOWN_LIBCALL; 49069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer} 49169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 49269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// getFPTOSINT - Return the FPTOSINT_*_* value for the given types, or 49369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// UNKNOWN_LIBCALL if there is none. 49469e42dbd006c0afb732067ece7327988b1e24c01Benjamin KramerRTLIB::Libcall RTLIB::getFPTOSINT(EVT OpVT, EVT RetVT) { 49569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (OpVT == MVT::f32) { 49669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i32) 49769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOSINT_F32_I32; 49869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i64) 49969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOSINT_F32_I64; 50069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i128) 50169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOSINT_F32_I128; 50269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } else if (OpVT == MVT::f64) { 50369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i32) 50469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOSINT_F64_I32; 50569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i64) 50669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOSINT_F64_I64; 50769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i128) 50869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOSINT_F64_I128; 50969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } else if (OpVT == MVT::f80) { 51069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i32) 51169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOSINT_F80_I32; 51269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i64) 51369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOSINT_F80_I64; 51469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i128) 51569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOSINT_F80_I128; 51669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } else if (OpVT == MVT::f128) { 51769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i32) 51869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOSINT_F128_I32; 51969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i64) 52069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOSINT_F128_I64; 52169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i128) 52269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOSINT_F128_I128; 52369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } else if (OpVT == MVT::ppcf128) { 52469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i32) 52569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOSINT_PPCF128_I32; 52669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i64) 52769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOSINT_PPCF128_I64; 52869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i128) 52969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOSINT_PPCF128_I128; 53069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 53169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return UNKNOWN_LIBCALL; 53269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer} 53369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 53469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// getFPTOUINT - Return the FPTOUINT_*_* value for the given types, or 53569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// UNKNOWN_LIBCALL if there is none. 53669e42dbd006c0afb732067ece7327988b1e24c01Benjamin KramerRTLIB::Libcall RTLIB::getFPTOUINT(EVT OpVT, EVT RetVT) { 53769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (OpVT == MVT::f32) { 53869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i32) 53969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOUINT_F32_I32; 54069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i64) 54169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOUINT_F32_I64; 54269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i128) 54369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOUINT_F32_I128; 54469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } else if (OpVT == MVT::f64) { 54569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i32) 54669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOUINT_F64_I32; 54769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i64) 54869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOUINT_F64_I64; 54969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i128) 55069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOUINT_F64_I128; 55169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } else if (OpVT == MVT::f80) { 55269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i32) 55369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOUINT_F80_I32; 55469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i64) 55569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOUINT_F80_I64; 55669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i128) 55769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOUINT_F80_I128; 55869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } else if (OpVT == MVT::f128) { 55969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i32) 56069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOUINT_F128_I32; 56169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i64) 56269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOUINT_F128_I64; 56369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i128) 56469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOUINT_F128_I128; 56569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } else if (OpVT == MVT::ppcf128) { 56669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i32) 56769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOUINT_PPCF128_I32; 56869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i64) 56969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOUINT_PPCF128_I64; 57069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::i128) 57169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return FPTOUINT_PPCF128_I128; 57269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 57369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return UNKNOWN_LIBCALL; 57469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer} 57569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 57669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// getSINTTOFP - Return the SINTTOFP_*_* value for the given types, or 57769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// UNKNOWN_LIBCALL if there is none. 57869e42dbd006c0afb732067ece7327988b1e24c01Benjamin KramerRTLIB::Libcall RTLIB::getSINTTOFP(EVT OpVT, EVT RetVT) { 57969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (OpVT == MVT::i32) { 58069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::f32) 58169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return SINTTOFP_I32_F32; 58269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::f64) 58369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return SINTTOFP_I32_F64; 58469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::f80) 58569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return SINTTOFP_I32_F80; 58669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::f128) 58769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return SINTTOFP_I32_F128; 58869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::ppcf128) 58969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return SINTTOFP_I32_PPCF128; 59069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } else if (OpVT == MVT::i64) { 59169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::f32) 59269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return SINTTOFP_I64_F32; 59369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::f64) 59469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return SINTTOFP_I64_F64; 59569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::f80) 59669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return SINTTOFP_I64_F80; 59769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::f128) 59869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return SINTTOFP_I64_F128; 59969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::ppcf128) 60069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return SINTTOFP_I64_PPCF128; 60169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } else if (OpVT == MVT::i128) { 60269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::f32) 60369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return SINTTOFP_I128_F32; 60469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::f64) 60569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return SINTTOFP_I128_F64; 60669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::f80) 60769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return SINTTOFP_I128_F80; 60869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::f128) 60969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return SINTTOFP_I128_F128; 61069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::ppcf128) 61169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return SINTTOFP_I128_PPCF128; 61269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 61369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return UNKNOWN_LIBCALL; 61469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer} 61569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 61669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// getUINTTOFP - Return the UINTTOFP_*_* value for the given types, or 61769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// UNKNOWN_LIBCALL if there is none. 61869e42dbd006c0afb732067ece7327988b1e24c01Benjamin KramerRTLIB::Libcall RTLIB::getUINTTOFP(EVT OpVT, EVT RetVT) { 61969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (OpVT == MVT::i32) { 62069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::f32) 62169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return UINTTOFP_I32_F32; 62269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::f64) 62369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return UINTTOFP_I32_F64; 62469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::f80) 62569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return UINTTOFP_I32_F80; 62669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::f128) 62769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return UINTTOFP_I32_F128; 62869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::ppcf128) 62969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return UINTTOFP_I32_PPCF128; 63069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } else if (OpVT == MVT::i64) { 63169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::f32) 63269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return UINTTOFP_I64_F32; 63369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::f64) 63469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return UINTTOFP_I64_F64; 63569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::f80) 63669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return UINTTOFP_I64_F80; 63769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::f128) 63869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return UINTTOFP_I64_F128; 63969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::ppcf128) 64069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return UINTTOFP_I64_PPCF128; 64169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } else if (OpVT == MVT::i128) { 64269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::f32) 64369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return UINTTOFP_I128_F32; 64469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::f64) 64569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return UINTTOFP_I128_F64; 64669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::f80) 64769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return UINTTOFP_I128_F80; 64869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::f128) 64969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return UINTTOFP_I128_F128; 65069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (RetVT == MVT::ppcf128) 65169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return UINTTOFP_I128_PPCF128; 65269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 65369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return UNKNOWN_LIBCALL; 65469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer} 65569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 6564c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga NainarRTLIB::Libcall RTLIB::getATOMIC(unsigned Opc, MVT VT) { 6574c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar#define OP_TO_LIBCALL(Name, Enum) \ 6584c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar case Name: \ 6594c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar switch (VT.SimpleTy) { \ 6604c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar default: \ 6614c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar return UNKNOWN_LIBCALL; \ 6624c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar case MVT::i8: \ 6634c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar return Enum##_1; \ 6644c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar case MVT::i16: \ 6654c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar return Enum##_2; \ 6664c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar case MVT::i32: \ 6674c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar return Enum##_4; \ 6684c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar case MVT::i64: \ 6694c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar return Enum##_8; \ 6704c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar case MVT::i128: \ 6714c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar return Enum##_16; \ 6724c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar } 6734c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar 6744c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar switch (Opc) { 6754c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar OP_TO_LIBCALL(ISD::ATOMIC_SWAP, SYNC_LOCK_TEST_AND_SET) 6764c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar OP_TO_LIBCALL(ISD::ATOMIC_CMP_SWAP, SYNC_VAL_COMPARE_AND_SWAP) 6774c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar OP_TO_LIBCALL(ISD::ATOMIC_LOAD_ADD, SYNC_FETCH_AND_ADD) 6784c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar OP_TO_LIBCALL(ISD::ATOMIC_LOAD_SUB, SYNC_FETCH_AND_SUB) 6794c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar OP_TO_LIBCALL(ISD::ATOMIC_LOAD_AND, SYNC_FETCH_AND_AND) 6804c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar OP_TO_LIBCALL(ISD::ATOMIC_LOAD_OR, SYNC_FETCH_AND_OR) 6814c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar OP_TO_LIBCALL(ISD::ATOMIC_LOAD_XOR, SYNC_FETCH_AND_XOR) 6824c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar OP_TO_LIBCALL(ISD::ATOMIC_LOAD_NAND, SYNC_FETCH_AND_NAND) 6834c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar OP_TO_LIBCALL(ISD::ATOMIC_LOAD_MAX, SYNC_FETCH_AND_MAX) 6844c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar OP_TO_LIBCALL(ISD::ATOMIC_LOAD_UMAX, SYNC_FETCH_AND_UMAX) 6854c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar OP_TO_LIBCALL(ISD::ATOMIC_LOAD_MIN, SYNC_FETCH_AND_MIN) 6864c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar OP_TO_LIBCALL(ISD::ATOMIC_LOAD_UMIN, SYNC_FETCH_AND_UMIN) 6874c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar } 6884c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar 6894c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar#undef OP_TO_LIBCALL 6904c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar 6914c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar return UNKNOWN_LIBCALL; 6924c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar} 6934c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar 69469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// InitCmpLibcallCCs - Set default comparison libcall CC. 69569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// 69669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramerstatic void InitCmpLibcallCCs(ISD::CondCode *CCs) { 69769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer memset(CCs, ISD::SETCC_INVALID, sizeof(ISD::CondCode)*RTLIB::UNKNOWN_LIBCALL); 69869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer CCs[RTLIB::OEQ_F32] = ISD::SETEQ; 69969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer CCs[RTLIB::OEQ_F64] = ISD::SETEQ; 70069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer CCs[RTLIB::OEQ_F128] = ISD::SETEQ; 70169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer CCs[RTLIB::UNE_F32] = ISD::SETNE; 70269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer CCs[RTLIB::UNE_F64] = ISD::SETNE; 70369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer CCs[RTLIB::UNE_F128] = ISD::SETNE; 70469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer CCs[RTLIB::OGE_F32] = ISD::SETGE; 70569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer CCs[RTLIB::OGE_F64] = ISD::SETGE; 70669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer CCs[RTLIB::OGE_F128] = ISD::SETGE; 70769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer CCs[RTLIB::OLT_F32] = ISD::SETLT; 70869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer CCs[RTLIB::OLT_F64] = ISD::SETLT; 70969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer CCs[RTLIB::OLT_F128] = ISD::SETLT; 71069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer CCs[RTLIB::OLE_F32] = ISD::SETLE; 71169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer CCs[RTLIB::OLE_F64] = ISD::SETLE; 71269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer CCs[RTLIB::OLE_F128] = ISD::SETLE; 71369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer CCs[RTLIB::OGT_F32] = ISD::SETGT; 71469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer CCs[RTLIB::OGT_F64] = ISD::SETGT; 71569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer CCs[RTLIB::OGT_F128] = ISD::SETGT; 71669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer CCs[RTLIB::UO_F32] = ISD::SETNE; 71769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer CCs[RTLIB::UO_F64] = ISD::SETNE; 71869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer CCs[RTLIB::UO_F128] = ISD::SETNE; 71969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer CCs[RTLIB::O_F32] = ISD::SETEQ; 72069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer CCs[RTLIB::O_F64] = ISD::SETEQ; 72169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer CCs[RTLIB::O_F128] = ISD::SETEQ; 72269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer} 72369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 72437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines/// NOTE: The TargetMachine owns TLOF. 7254c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga NainarTargetLoweringBase::TargetLoweringBase(const TargetMachine &tm) : TM(tm) { 72613bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling initActions(); 72713bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling 72813bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling // Perform these initializations only once. 72913bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling MaxStoresPerMemset = MaxStoresPerMemcpy = MaxStoresPerMemmove = 8; 73013bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling MaxStoresPerMemsetOptSize = MaxStoresPerMemcpyOptSize 73113bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling = MaxStoresPerMemmoveOptSize = 4; 73213bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling UseUnderscoreSetJmp = false; 73313bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling UseUnderscoreLongJmp = false; 73413bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling SelectIsExpensive = false; 73536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines HasMultipleConditionRegisters = false; 736dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines HasExtractBitsInsn = false; 737ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines FsqrtIsCheap = false; 738cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar JumpIsExpensive = JumpIsExpensiveOverride; 73913bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling PredictableSelectIsExpensive = false; 74036b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines MaskAndBranchFoldingIsLegal = false; 741ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines EnableExtLdPromotion = false; 74237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines HasFloatingPointExceptions = true; 74313bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling StackPointerRegisterToSaveRestore = 0; 74413bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling BooleanContents = UndefinedBooleanContent; 745c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines BooleanFloatContents = UndefinedBooleanContent; 74613bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling BooleanVectorContents = UndefinedBooleanContent; 74713bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling SchedPreferenceInfo = Sched::ILP; 74813bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling JumpBufSize = 0; 74913bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling JumpBufAlignment = 0; 75013bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling MinFunctionAlignment = 0; 75113bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling PrefFunctionAlignment = 0; 75213bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling PrefLoopAlignment = 0; 753cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar GatherAllAliasesMaxDepth = 6; 75413bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling MinStackArgumentAlignment = 1; 75513bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling InsertFencesForAtomic = false; 75613bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling MinimumJumpTableEntries = 4; 75713bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling 758cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar InitLibcallNames(LibcallRoutineNames, TM.getTargetTriple()); 75913bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling InitCmpLibcallCCs(CmpLibcallCCs); 76013bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling InitLibcallCallingConvs(LibcallCallingConvs); 76113bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling} 76213bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling 76313bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendlingvoid TargetLoweringBase::initActions() { 76469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // All operations default to being supported. 76569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer memset(OpActions, 0, sizeof(OpActions)); 76669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer memset(LoadExtActions, 0, sizeof(LoadExtActions)); 76769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer memset(TruncStoreActions, 0, sizeof(TruncStoreActions)); 76869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer memset(IndexedModeActions, 0, sizeof(IndexedModeActions)); 76969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer memset(CondCodeActions, 0, sizeof(CondCodeActions)); 77013bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling memset(RegClassForVT, 0,MVT::LAST_VALUETYPE*sizeof(TargetRegisterClass*)); 77113bbe1f52e8d57151e2730db49094e1c62a4c793Bill Wendling memset(TargetDAGCombineArray, 0, array_lengthof(TargetDAGCombineArray)); 77269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 77369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Set default actions for various operations. 774ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines for (MVT VT : MVT::all_valuetypes()) { 77569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Default all indexed load / store to expand. 77669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer for (unsigned IM = (unsigned)ISD::PRE_INC; 77769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer IM != (unsigned)ISD::LAST_INDEXED_MODE; ++IM) { 778ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines setIndexedLoadAction(IM, VT, Expand); 779ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines setIndexedStoreAction(IM, VT, Expand); 78069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 78169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 782c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines // Most backends expect to see the node which just returns the value loaded. 783ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines setOperationAction(ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS, VT, Expand); 784c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines 78569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // These operations default to expand. 786ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines setOperationAction(ISD::FGETSIGN, VT, Expand); 787ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines setOperationAction(ISD::CONCAT_VECTORS, VT, Expand); 788ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines setOperationAction(ISD::FMINNUM, VT, Expand); 789ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines setOperationAction(ISD::FMAXNUM, VT, Expand); 790cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar setOperationAction(ISD::FMINNAN, VT, Expand); 791cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar setOperationAction(ISD::FMAXNAN, VT, Expand); 792ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines setOperationAction(ISD::FMAD, VT, Expand); 7936948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar setOperationAction(ISD::SMIN, VT, Expand); 7946948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar setOperationAction(ISD::SMAX, VT, Expand); 7956948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar setOperationAction(ISD::UMIN, VT, Expand); 7966948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar setOperationAction(ISD::UMAX, VT, Expand); 7976948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar 7986948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar // Overflow operations default to expand 7996948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar setOperationAction(ISD::SADDO, VT, Expand); 8006948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar setOperationAction(ISD::SSUBO, VT, Expand); 8016948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar setOperationAction(ISD::UADDO, VT, Expand); 8026948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar setOperationAction(ISD::USUBO, VT, Expand); 8036948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar setOperationAction(ISD::SMULO, VT, Expand); 8046948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar setOperationAction(ISD::UMULO, VT, Expand); 8053d7f79a02e143cfcbc85ea2091f2797285a9db84Hal Finkel 806cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar setOperationAction(ISD::BITREVERSE, VT, Expand); 807cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar 8083d7f79a02e143cfcbc85ea2091f2797285a9db84Hal Finkel // These library functions default to expand. 809ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines setOperationAction(ISD::FROUND, VT, Expand); 81066d1fa6f4b443ac9f8bcea5d1f71a73ada733a42Hal Finkel 81166d1fa6f4b443ac9f8bcea5d1f71a73ada733a42Hal Finkel // These operations default to expand for vector types. 812ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines if (VT.isVector()) { 813ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines setOperationAction(ISD::FCOPYSIGN, VT, Expand); 814ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines setOperationAction(ISD::ANY_EXTEND_VECTOR_INREG, VT, Expand); 815ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines setOperationAction(ISD::SIGN_EXTEND_VECTOR_INREG, VT, Expand); 816ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines setOperationAction(ISD::ZERO_EXTEND_VECTOR_INREG, VT, Expand); 817c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines } 818cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar 819cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar // For most targets @llvm.get.dynamic.area.offest just returns 0. 820cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar setOperationAction(ISD::GET_DYNAMIC_AREA_OFFSET, VT, Expand); 82169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 82269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 82369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Most targets ignore the @llvm.prefetch intrinsic. 82469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer setOperationAction(ISD::PREFETCH, MVT::Other, Expand); 82569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 826cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar // Most targets also ignore the @llvm.readcyclecounter intrinsic. 827cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar setOperationAction(ISD::READCYCLECOUNTER, MVT::i64, Expand); 828cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar 82969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // ConstantFP nodes default to expand. Targets can either change this to 83069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Legal, in which case all fp constants are legal, or use isFPImmLegal() 83169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // to optimize expansions for certain constants. 83269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer setOperationAction(ISD::ConstantFP, MVT::f16, Expand); 83369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer setOperationAction(ISD::ConstantFP, MVT::f32, Expand); 83469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer setOperationAction(ISD::ConstantFP, MVT::f64, Expand); 83569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer setOperationAction(ISD::ConstantFP, MVT::f80, Expand); 83669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer setOperationAction(ISD::ConstantFP, MVT::f128, Expand); 83769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 83869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // These library functions default to expand. 8394c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar for (MVT VT : {MVT::f32, MVT::f64, MVT::f128}) { 8404c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar setOperationAction(ISD::FLOG , VT, Expand); 8414c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar setOperationAction(ISD::FLOG2, VT, Expand); 8424c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar setOperationAction(ISD::FLOG10, VT, Expand); 8434c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar setOperationAction(ISD::FEXP , VT, Expand); 8444c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar setOperationAction(ISD::FEXP2, VT, Expand); 8454c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar setOperationAction(ISD::FFLOOR, VT, Expand); 8464c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar setOperationAction(ISD::FMINNUM, VT, Expand); 8474c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar setOperationAction(ISD::FMAXNUM, VT, Expand); 8484c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar setOperationAction(ISD::FNEARBYINT, VT, Expand); 8494c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar setOperationAction(ISD::FCEIL, VT, Expand); 8504c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar setOperationAction(ISD::FRINT, VT, Expand); 8514c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar setOperationAction(ISD::FTRUNC, VT, Expand); 8524c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar setOperationAction(ISD::FROUND, VT, Expand); 8534c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar } 85469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 85569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Default ISD::TRAP to expand (which turns it into abort). 85669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer setOperationAction(ISD::TRAP, MVT::Other, Expand); 85769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 85869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // On most systems, DEBUGTRAP and TRAP have no difference. The "Expand" 85969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // here is to inform DAG Legalizer to replace DEBUGTRAP with TRAP. 86069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // 86169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer setOperationAction(ISD::DEBUGTRAP, MVT::Other, Expand); 86269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer} 86369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 864cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga NainarMVT TargetLoweringBase::getScalarShiftAmountTy(const DataLayout &DL, 865cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar EVT) const { 866cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar return MVT::getIntegerVT(8 * DL.getPointerSize(0)); 86769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer} 86869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 869cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga NainarEVT TargetLoweringBase::getShiftAmountTy(EVT LHSTy, 870cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar const DataLayout &DL) const { 871a6b20ced765b67a85d9219d0c8547fc9c133e14fMichael Liao assert(LHSTy.isInteger() && "Shift amount is not an integer type!"); 872a6b20ced765b67a85d9219d0c8547fc9c133e14fMichael Liao if (LHSTy.isVector()) 873a6b20ced765b67a85d9219d0c8547fc9c133e14fMichael Liao return LHSTy; 874cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar return getScalarShiftAmountTy(DL, LHSTy); 875a6b20ced765b67a85d9219d0c8547fc9c133e14fMichael Liao} 876a6b20ced765b67a85d9219d0c8547fc9c133e14fMichael Liao 87769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// canOpTrap - Returns true if the operation can trap for the value type. 87869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// VT must be a legal type. 87969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramerbool TargetLoweringBase::canOpTrap(unsigned Op, EVT VT) const { 88069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer assert(isTypeLegal(VT)); 88169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer switch (Op) { 88269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer default: 88369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return false; 88469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case ISD::FDIV: 88569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case ISD::FREM: 88669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case ISD::SDIV: 88769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case ISD::UDIV: 88869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case ISD::SREM: 88969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case ISD::UREM: 89069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return true; 89169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 89269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer} 89369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 894cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainarvoid TargetLoweringBase::setJumpIsExpensive(bool isExpensive) { 895cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar // If the command-line option was specified, ignore this request. 896cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar if (!JumpIsExpensiveOverride.getNumOccurrences()) 897cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar JumpIsExpensive = isExpensive; 898cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar} 899cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar 900ebe69fe11e48d322045d5949c83283927a0d790bStephen HinesTargetLoweringBase::LegalizeKind 901ebe69fe11e48d322045d5949c83283927a0d790bStephen HinesTargetLoweringBase::getTypeConversion(LLVMContext &Context, EVT VT) const { 902ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // If this is a simple type, use the ComputeRegisterProp mechanism. 903ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines if (VT.isSimple()) { 904ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines MVT SVT = VT.getSimpleVT(); 905ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines assert((unsigned)SVT.SimpleTy < array_lengthof(TransformToType)); 906ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines MVT NVT = TransformToType[SVT.SimpleTy]; 907ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines LegalizeTypeAction LA = ValueTypeActions.getTypeAction(SVT); 908ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 909ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines assert((LA == TypeLegal || LA == TypeSoftenFloat || 910ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines ValueTypeActions.getTypeAction(NVT) != TypePromoteInteger) && 911ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines "Promote may not follow Expand or Promote"); 912ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 913ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines if (LA == TypeSplitVector) 914ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines return LegalizeKind(LA, 915ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines EVT::getVectorVT(Context, SVT.getVectorElementType(), 916ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines SVT.getVectorNumElements() / 2)); 917ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines if (LA == TypeScalarizeVector) 918ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines return LegalizeKind(LA, SVT.getVectorElementType()); 919ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines return LegalizeKind(LA, NVT); 920ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines } 921ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 922ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // Handle Extended Scalar Types. 923ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines if (!VT.isVector()) { 924ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines assert(VT.isInteger() && "Float types must be simple"); 925ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines unsigned BitSize = VT.getSizeInBits(); 926ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // First promote to a power-of-two size, then expand if necessary. 927ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines if (BitSize < 8 || !isPowerOf2_32(BitSize)) { 928ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines EVT NVT = VT.getRoundIntegerType(Context); 929ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines assert(NVT != VT && "Unable to round integer VT"); 930ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines LegalizeKind NextStep = getTypeConversion(Context, NVT); 931ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // Avoid multi-step promotion. 932ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines if (NextStep.first == TypePromoteInteger) 933ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines return NextStep; 934ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // Return rounded integer type. 935ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines return LegalizeKind(TypePromoteInteger, NVT); 936ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines } 937ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 938ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines return LegalizeKind(TypeExpandInteger, 939ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines EVT::getIntegerVT(Context, VT.getSizeInBits() / 2)); 940ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines } 941ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 942ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // Handle vector types. 943ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines unsigned NumElts = VT.getVectorNumElements(); 944ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines EVT EltVT = VT.getVectorElementType(); 945ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 946ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // Vectors with only one element are always scalarized. 947ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines if (NumElts == 1) 948ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines return LegalizeKind(TypeScalarizeVector, EltVT); 949ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 950ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // Try to widen vector elements until the element type is a power of two and 951ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // promote it to a legal type later on, for example: 952ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // <3 x i8> -> <4 x i8> -> <4 x i32> 953ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines if (EltVT.isInteger()) { 954ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // Vectors with a number of elements that is not a power of two are always 955ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // widened, for example <3 x i8> -> <4 x i8>. 956ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines if (!VT.isPow2VectorType()) { 957ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines NumElts = (unsigned)NextPowerOf2(NumElts); 958ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines EVT NVT = EVT::getVectorVT(Context, EltVT, NumElts); 959ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines return LegalizeKind(TypeWidenVector, NVT); 960ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines } 961ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 962ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // Examine the element type. 963ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines LegalizeKind LK = getTypeConversion(Context, EltVT); 964ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 965ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // If type is to be expanded, split the vector. 966ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // <4 x i140> -> <2 x i140> 967ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines if (LK.first == TypeExpandInteger) 968ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines return LegalizeKind(TypeSplitVector, 969ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines EVT::getVectorVT(Context, EltVT, NumElts / 2)); 970ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 971ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // Promote the integer element types until a legal vector type is found 972ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // or until the element integer type is too big. If a legal type was not 973ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // found, fallback to the usual mechanism of widening/splitting the 974ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // vector. 975ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines EVT OldEltVT = EltVT; 976ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines while (1) { 977ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // Increase the bitwidth of the element to the next pow-of-two 978ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // (which is greater than 8 bits). 979ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines EltVT = EVT::getIntegerVT(Context, 1 + EltVT.getSizeInBits()) 980ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines .getRoundIntegerType(Context); 981ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 982ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // Stop trying when getting a non-simple element type. 983ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // Note that vector elements may be greater than legal vector element 984ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // types. Example: X86 XMM registers hold 64bit element on 32bit 985ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // systems. 986ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines if (!EltVT.isSimple()) 987ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines break; 988ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 989ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // Build a new vector type and check if it is legal. 990ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines MVT NVT = MVT::getVectorVT(EltVT.getSimpleVT(), NumElts); 991ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // Found a legal promoted vector type. 992ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines if (NVT != MVT() && ValueTypeActions.getTypeAction(NVT) == TypeLegal) 993ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines return LegalizeKind(TypePromoteInteger, 994ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines EVT::getVectorVT(Context, EltVT, NumElts)); 995ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines } 996ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 997ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // Reset the type to the unexpanded type if we did not find a legal vector 998ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // type with a promoted vector element type. 999ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines EltVT = OldEltVT; 1000ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines } 1001ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 1002ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // Try to widen the vector until a legal type is found. 1003ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // If there is no wider legal type, split the vector. 1004ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines while (1) { 1005ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // Round up to the next power of 2. 1006ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines NumElts = (unsigned)NextPowerOf2(NumElts); 1007ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 1008ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // If there is no simple vector type with this many elements then there 1009ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // cannot be a larger legal vector type. Note that this assumes that 1010ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // there are no skipped intermediate vector types in the simple types. 1011ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines if (!EltVT.isSimple()) 1012ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines break; 1013ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines MVT LargerVector = MVT::getVectorVT(EltVT.getSimpleVT(), NumElts); 1014ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines if (LargerVector == MVT()) 1015ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines break; 1016ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 1017ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // If this type is legal then widen the vector. 1018ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines if (ValueTypeActions.getTypeAction(LargerVector) == TypeLegal) 1019ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines return LegalizeKind(TypeWidenVector, LargerVector); 1020ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines } 1021ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 1022ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // Widen odd vectors to next power of two. 1023ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines if (!VT.isPow2VectorType()) { 1024ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines EVT NVT = VT.getPow2VectorType(Context); 1025ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines return LegalizeKind(TypeWidenVector, NVT); 1026ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines } 1027ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 1028ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines // Vectors with illegal element types are expanded. 1029ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines EVT NVT = EVT::getVectorVT(Context, EltVT, VT.getVectorNumElements() / 2); 1030ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines return LegalizeKind(TypeSplitVector, NVT); 1031ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines} 103269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 103369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramerstatic unsigned getVectorTypeBreakdownMVT(MVT VT, MVT &IntermediateVT, 103469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer unsigned &NumIntermediates, 103569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer MVT &RegisterVT, 103669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer TargetLoweringBase *TLI) { 103769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Figure out the right, legal destination reg to copy into. 103869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer unsigned NumElts = VT.getVectorNumElements(); 103969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer MVT EltTy = VT.getVectorElementType(); 104069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 104169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer unsigned NumVectorRegs = 1; 104269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 104369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // FIXME: We don't support non-power-of-2-sized vectors for now. Ideally we 104469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // could break down into LHS/RHS like LegalizeDAG does. 104569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (!isPowerOf2_32(NumElts)) { 104669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer NumVectorRegs = NumElts; 104769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer NumElts = 1; 104869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 104969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 105069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Divide the input until we get to a supported size. This will always 105169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // end with a scalar if the target doesn't support vectors. 105269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer while (NumElts > 1 && !TLI->isTypeLegal(MVT::getVectorVT(EltTy, NumElts))) { 105369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer NumElts >>= 1; 105469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer NumVectorRegs <<= 1; 105569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 105669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 105769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer NumIntermediates = NumVectorRegs; 105869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 105969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer MVT NewVT = MVT::getVectorVT(EltTy, NumElts); 106069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (!TLI->isTypeLegal(NewVT)) 106169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer NewVT = EltTy; 106269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer IntermediateVT = NewVT; 106369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 106469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer unsigned NewVTSize = NewVT.getSizeInBits(); 106569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 106669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Convert sizes such as i33 to i64. 106769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (!isPowerOf2_32(NewVTSize)) 106869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer NewVTSize = NextPowerOf2(NewVTSize); 106969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 107069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer MVT DestVT = TLI->getRegisterType(NewVT); 107169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer RegisterVT = DestVT; 107269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (EVT(DestVT).bitsLT(NewVT)) // Value is expanded, e.g. i64 -> i16. 107369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return NumVectorRegs*(NewVTSize/DestVT.getSizeInBits()); 107469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 107569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Otherwise, promotion or legal types use the same number of registers as 107669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // the vector decimated to the appropriate level. 107769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return NumVectorRegs; 107869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer} 107969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 108069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// isLegalRC - Return true if the value types that can be represented by the 108169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// specified register class are all legal. 108269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramerbool TargetLoweringBase::isLegalRC(const TargetRegisterClass *RC) const { 108369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer for (TargetRegisterClass::vt_iterator I = RC->vt_begin(), E = RC->vt_end(); 108469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer I != E; ++I) { 108569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (isTypeLegal(*I)) 108669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return true; 108769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 108869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return false; 108969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer} 109069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 109136b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines/// Replace/modify any TargetFrameIndex operands with a targte-dependent 109236b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines/// sequence of memory operands that is recognized by PrologEpilogInserter. 109336b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen HinesMachineBasicBlock* 109436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen HinesTargetLoweringBase::emitPatchPoint(MachineInstr *MI, 109536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines MachineBasicBlock *MBB) const { 109636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines MachineFunction &MF = *MI->getParent()->getParent(); 109736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines 109836b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines // MI changes inside this loop as we grow operands. 109936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines for(unsigned OperIdx = 0; OperIdx != MI->getNumOperands(); ++OperIdx) { 110036b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines MachineOperand &MO = MI->getOperand(OperIdx); 110136b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines if (!MO.isFI()) 110236b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines continue; 110336b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines 110436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines // foldMemoryOperand builds a new MI after replacing a single FI operand 110536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines // with the canonical set of five x86 addressing-mode operands. 110636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines int FI = MO.getIndex(); 110736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines MachineInstrBuilder MIB = BuildMI(MF, MI->getDebugLoc(), MI->getDesc()); 110836b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines 110936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines // Copy operands before the frame-index. 111036b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines for (unsigned i = 0; i < OperIdx; ++i) 111136b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines MIB.addOperand(MI->getOperand(i)); 111236b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines // Add frame index operands: direct-mem-ref tag, #FI, offset. 111336b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines MIB.addImm(StackMaps::DirectMemRefOp); 111436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines MIB.addOperand(MI->getOperand(OperIdx)); 111536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines MIB.addImm(0); 111636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines // Copy the operands after the frame index. 111736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines for (unsigned i = OperIdx + 1; i != MI->getNumOperands(); ++i) 111836b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines MIB.addOperand(MI->getOperand(i)); 111936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines 112036b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines // Inherit previous memory operands. 112136b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines MIB->setMemRefs(MI->memoperands_begin(), MI->memoperands_end()); 112236b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines assert(MIB->mayLoad() && "Folded a stackmap use to a non-load!"); 112336b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines 112436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines // Add a new memory operand for this FI. 112536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines const MachineFrameInfo &MFI = *MF.getFrameInfo(); 112636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines assert(MFI.getObjectOffset(FI) != -1); 1127ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 1128ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines unsigned Flags = MachineMemOperand::MOLoad; 1129ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines if (MI->getOpcode() == TargetOpcode::STATEPOINT) { 1130ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines Flags |= MachineMemOperand::MOStore; 1131ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines Flags |= MachineMemOperand::MOVolatile; 1132ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines } 113337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines MachineMemOperand *MMO = MF.getMachineMemOperand( 1134cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar MachinePointerInfo::getFixedStack(MF, FI), Flags, 1135cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar MF.getDataLayout().getPointerSize(), MFI.getObjectAlignment(FI)); 113636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines MIB->addMemOperand(MF, MMO); 113736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines 113836b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines // Replace the instruction and update the operand index. 113936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines MBB->insert(MachineBasicBlock::iterator(MI), MIB); 114036b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines OperIdx += (MIB->getNumOperands() - MI->getNumOperands()) - 1; 114136b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines MI->eraseFromParent(); 114236b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines MI = MIB; 114336b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines } 114436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines return MBB; 114536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines} 114636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines 114769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// findRepresentativeClass - Return the largest legal super-reg register class 114869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// of the register class for the specified type and its associated "cost". 11494c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar// This function is in TargetLowering because it uses RegClassForVT which would 11504c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar// need to be moved to TargetRegisterInfo and would necessitate moving 11514c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar// isTypeLegal over as well - a massive change that would just require 11524c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar// TargetLowering having a TargetRegisterInfo class member that it would use. 1153ebe69fe11e48d322045d5949c83283927a0d790bStephen Hinesstd::pair<const TargetRegisterClass *, uint8_t> 1154ebe69fe11e48d322045d5949c83283927a0d790bStephen HinesTargetLoweringBase::findRepresentativeClass(const TargetRegisterInfo *TRI, 1155ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines MVT VT) const { 115669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer const TargetRegisterClass *RC = RegClassForVT[VT.SimpleTy]; 115769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (!RC) 115869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return std::make_pair(RC, 0); 115969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 116069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Compute the set of all super-register classes. 116169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer BitVector SuperRegRC(TRI->getNumRegClasses()); 116269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer for (SuperRegClassIterator RCI(RC, TRI); RCI.isValid(); ++RCI) 116369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer SuperRegRC.setBitsInMask(RCI.getMask()); 116469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 116569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Find the first legal register class with the largest spill size. 116669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer const TargetRegisterClass *BestRC = RC; 116769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer for (int i = SuperRegRC.find_first(); i >= 0; i = SuperRegRC.find_next(i)) { 116869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer const TargetRegisterClass *SuperRC = TRI->getRegClass(i); 116969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // We want the largest possible spill size. 117069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (SuperRC->getSize() <= BestRC->getSize()) 117169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer continue; 117269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (!isLegalRC(SuperRC)) 117369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer continue; 117469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer BestRC = SuperRC; 117569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 117669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return std::make_pair(BestRC, 1); 117769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer} 117869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 117969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// computeRegisterProperties - Once all of the register classes are added, 118069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// this allows us to compute derived properties we expose. 1181ebe69fe11e48d322045d5949c83283927a0d790bStephen Hinesvoid TargetLoweringBase::computeRegisterProperties( 1182ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines const TargetRegisterInfo *TRI) { 118337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines static_assert(MVT::LAST_VALUETYPE <= MVT::MAX_ALLOWED_VALUETYPE, 118437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines "Too many value types for ValueTypeActions to hold!"); 118569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 118669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Everything defaults to needing one register. 118769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer for (unsigned i = 0; i != MVT::LAST_VALUETYPE; ++i) { 118869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer NumRegistersForVT[i] = 1; 118969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer RegisterTypeForVT[i] = TransformToType[i] = (MVT::SimpleValueType)i; 119069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 119169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // ...except isVoid, which doesn't need any registers. 119269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer NumRegistersForVT[MVT::isVoid] = 0; 119369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 119469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Find the largest integer register class. 119569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer unsigned LargestIntReg = MVT::LAST_INTEGER_VALUETYPE; 1196dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines for (; RegClassForVT[LargestIntReg] == nullptr; --LargestIntReg) 119769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer assert(LargestIntReg != MVT::i1 && "No integer registers defined!"); 119869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 119969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Every integer value type larger than this largest register takes twice as 120069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // many registers to represent as the previous ValueType. 120169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer for (unsigned ExpandedReg = LargestIntReg + 1; 120269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer ExpandedReg <= MVT::LAST_INTEGER_VALUETYPE; ++ExpandedReg) { 120369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer NumRegistersForVT[ExpandedReg] = 2*NumRegistersForVT[ExpandedReg-1]; 120469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer RegisterTypeForVT[ExpandedReg] = (MVT::SimpleValueType)LargestIntReg; 120569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer TransformToType[ExpandedReg] = (MVT::SimpleValueType)(ExpandedReg - 1); 120669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer ValueTypeActions.setTypeAction((MVT::SimpleValueType)ExpandedReg, 120769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer TypeExpandInteger); 120869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 120969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 121069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Inspect all of the ValueType's smaller than the largest integer 121169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // register to see which ones need promotion. 121269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer unsigned LegalIntReg = LargestIntReg; 121369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer for (unsigned IntReg = LargestIntReg - 1; 121469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer IntReg >= (unsigned)MVT::i1; --IntReg) { 121569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer MVT IVT = (MVT::SimpleValueType)IntReg; 121669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (isTypeLegal(IVT)) { 121769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer LegalIntReg = IntReg; 121869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } else { 121969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer RegisterTypeForVT[IntReg] = TransformToType[IntReg] = 122069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer (const MVT::SimpleValueType)LegalIntReg; 122169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer ValueTypeActions.setTypeAction(IVT, TypePromoteInteger); 122269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 122369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 122469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 122569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // ppcf128 type is really two f64's. 122669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (!isTypeLegal(MVT::ppcf128)) { 122769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer NumRegistersForVT[MVT::ppcf128] = 2*NumRegistersForVT[MVT::f64]; 122869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer RegisterTypeForVT[MVT::ppcf128] = MVT::f64; 122969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer TransformToType[MVT::ppcf128] = MVT::f64; 123069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer ValueTypeActions.setTypeAction(MVT::ppcf128, TypeExpandFloat); 123169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 123269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 1233c3c3810f514af7e08f84ef76b0c304ec264ee021Akira Hatanaka // Decide how to handle f128. If the target does not have native f128 support, 1234c3c3810f514af7e08f84ef76b0c304ec264ee021Akira Hatanaka // expand it to i128 and we will be generating soft float library calls. 1235c3c3810f514af7e08f84ef76b0c304ec264ee021Akira Hatanaka if (!isTypeLegal(MVT::f128)) { 1236c3c3810f514af7e08f84ef76b0c304ec264ee021Akira Hatanaka NumRegistersForVT[MVT::f128] = NumRegistersForVT[MVT::i128]; 1237c3c3810f514af7e08f84ef76b0c304ec264ee021Akira Hatanaka RegisterTypeForVT[MVT::f128] = RegisterTypeForVT[MVT::i128]; 1238c3c3810f514af7e08f84ef76b0c304ec264ee021Akira Hatanaka TransformToType[MVT::f128] = MVT::i128; 1239c3c3810f514af7e08f84ef76b0c304ec264ee021Akira Hatanaka ValueTypeActions.setTypeAction(MVT::f128, TypeSoftenFloat); 1240c3c3810f514af7e08f84ef76b0c304ec264ee021Akira Hatanaka } 1241c3c3810f514af7e08f84ef76b0c304ec264ee021Akira Hatanaka 124269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Decide how to handle f64. If the target does not have native f64 support, 124369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // expand it to i64 and we will be generating soft float library calls. 124469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (!isTypeLegal(MVT::f64)) { 124569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer NumRegistersForVT[MVT::f64] = NumRegistersForVT[MVT::i64]; 124669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer RegisterTypeForVT[MVT::f64] = RegisterTypeForVT[MVT::i64]; 124769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer TransformToType[MVT::f64] = MVT::i64; 124869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer ValueTypeActions.setTypeAction(MVT::f64, TypeSoftenFloat); 124969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 125069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 12510c7f116bb6950ef819323d855415b2f2b0aad987Pirama Arumuga Nainar // Decide how to handle f32. If the target does not have native f32 support, 12520c7f116bb6950ef819323d855415b2f2b0aad987Pirama Arumuga Nainar // expand it to i32 and we will be generating soft float library calls. 125369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (!isTypeLegal(MVT::f32)) { 12540c7f116bb6950ef819323d855415b2f2b0aad987Pirama Arumuga Nainar NumRegistersForVT[MVT::f32] = NumRegistersForVT[MVT::i32]; 12550c7f116bb6950ef819323d855415b2f2b0aad987Pirama Arumuga Nainar RegisterTypeForVT[MVT::f32] = RegisterTypeForVT[MVT::i32]; 12560c7f116bb6950ef819323d855415b2f2b0aad987Pirama Arumuga Nainar TransformToType[MVT::f32] = MVT::i32; 12570c7f116bb6950ef819323d855415b2f2b0aad987Pirama Arumuga Nainar ValueTypeActions.setTypeAction(MVT::f32, TypeSoftenFloat); 125869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 125969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 1260cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar // Decide how to handle f16. If the target does not have native f16 support, 1261cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar // promote it to f32, because there are no f16 library calls (except for 1262cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar // conversions). 126337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines if (!isTypeLegal(MVT::f16)) { 1264cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar NumRegistersForVT[MVT::f16] = NumRegistersForVT[MVT::f32]; 1265cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar RegisterTypeForVT[MVT::f16] = RegisterTypeForVT[MVT::f32]; 1266cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar TransformToType[MVT::f16] = MVT::f32; 1267cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar ValueTypeActions.setTypeAction(MVT::f16, TypePromoteFloat); 126837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines } 126937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines 127069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Loop over all of the vector value types to see which need transformations. 127169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer for (unsigned i = MVT::FIRST_VECTOR_VALUETYPE; 127269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer i <= (unsigned)MVT::LAST_VECTOR_VALUETYPE; ++i) { 1273c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines MVT VT = (MVT::SimpleValueType) i; 1274c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines if (isTypeLegal(VT)) 1275c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines continue; 127669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 127769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer MVT EltVT = VT.getVectorElementType(); 127869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer unsigned NElts = VT.getVectorNumElements(); 1279c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines bool IsLegalWiderType = false; 1280c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines LegalizeTypeAction PreferredAction = getPreferredVectorAction(VT); 1281c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines switch (PreferredAction) { 1282c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines case TypePromoteInteger: { 1283c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines // Try to promote the elements of integer vectors. If no legal 1284c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines // promotion was found, fall through to the widen-vector method. 1285c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines for (unsigned nVT = i + 1; nVT <= MVT::LAST_VECTOR_VALUETYPE; ++nVT) { 1286c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines MVT SVT = (MVT::SimpleValueType) nVT; 128769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Promote vectors of integers to vectors with the same number 128869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // of elements, with a wider element type. 128969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (SVT.getVectorElementType().getSizeInBits() > EltVT.getSizeInBits() 1290c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines && SVT.getVectorNumElements() == NElts && isTypeLegal(SVT) 1291c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines && SVT.getScalarType().isInteger()) { 129269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer TransformToType[i] = SVT; 129369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer RegisterTypeForVT[i] = SVT; 129469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer NumRegistersForVT[i] = 1; 129569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer ValueTypeActions.setTypeAction(VT, TypePromoteInteger); 129669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer IsLegalWiderType = true; 129769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer break; 129869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 129969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 1300c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines if (IsLegalWiderType) 1301c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines break; 1302c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines } 1303c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines case TypeWidenVector: { 130469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Try to widen the vector. 1305c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines for (unsigned nVT = i + 1; nVT <= MVT::LAST_VECTOR_VALUETYPE; ++nVT) { 1306c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines MVT SVT = (MVT::SimpleValueType) nVT; 1307c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines if (SVT.getVectorElementType() == EltVT 1308c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines && SVT.getVectorNumElements() > NElts && isTypeLegal(SVT)) { 130969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer TransformToType[i] = SVT; 131069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer RegisterTypeForVT[i] = SVT; 131169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer NumRegistersForVT[i] = 1; 131269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer ValueTypeActions.setTypeAction(VT, TypeWidenVector); 131369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer IsLegalWiderType = true; 131469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer break; 131569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 131669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 1317c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines if (IsLegalWiderType) 1318c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines break; 131969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 1320c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines case TypeSplitVector: 1321c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines case TypeScalarizeVector: { 1322c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines MVT IntermediateVT; 1323c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines MVT RegisterVT; 1324c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines unsigned NumIntermediates; 1325c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines NumRegistersForVT[i] = getVectorTypeBreakdownMVT(VT, IntermediateVT, 1326c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines NumIntermediates, RegisterVT, this); 1327c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines RegisterTypeForVT[i] = RegisterVT; 1328c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines 1329c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines MVT NVT = VT.getPow2VectorType(); 1330c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines if (NVT == VT) { 1331c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines // Type is already a power of 2. The default action is to split. 1332c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines TransformToType[i] = MVT::Other; 1333c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines if (PreferredAction == TypeScalarizeVector) 1334c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines ValueTypeActions.setTypeAction(VT, TypeScalarizeVector); 133537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines else if (PreferredAction == TypeSplitVector) 1336c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines ValueTypeActions.setTypeAction(VT, TypeSplitVector); 133737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines else 133837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines // Set type action according to the number of elements. 133937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines ValueTypeActions.setTypeAction(VT, NElts == 1 ? TypeScalarizeVector 134037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines : TypeSplitVector); 1341c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines } else { 1342c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines TransformToType[i] = NVT; 1343c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines ValueTypeActions.setTypeAction(VT, TypeWidenVector); 1344c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines } 1345c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines break; 1346c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines } 1347c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines default: 1348c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines llvm_unreachable("Unknown vector legalization action!"); 134969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 135069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 135169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 135269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Determine the 'representative' register class for each value type. 135369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // An representative register class is the largest (meaning one which is 135469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // not a sub-register class / subreg register class) legal register class for 135569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // a group of value types. For example, on i386, i8, i16, and i32 135669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // representative would be GR32; while on x86_64 it's GR64. 135769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer for (unsigned i = 0; i != MVT::LAST_VALUETYPE; ++i) { 135869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer const TargetRegisterClass* RRC; 135969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer uint8_t Cost; 1360ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines std::tie(RRC, Cost) = findRepresentativeClass(TRI, (MVT::SimpleValueType)i); 136169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer RepRegClassForVT[i] = RRC; 136269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer RepRegClassCostForVT[i] = Cost; 136369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 136469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer} 136569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 1366cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga NainarEVT TargetLoweringBase::getSetCCResultType(const DataLayout &DL, LLVMContext &, 1367cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar EVT VT) const { 136869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer assert(!VT.isVector() && "No default SetCC type for vectors!"); 1369cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar return getPointerTy(DL).SimpleTy; 137069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer} 137169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 137269e42dbd006c0afb732067ece7327988b1e24c01Benjamin KramerMVT::SimpleValueType TargetLoweringBase::getCmpLibcallReturnType() const { 137369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return MVT::i32; // return the default value 137469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer} 137569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 137669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// getVectorTypeBreakdown - Vector types are broken down into some number of 137769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// legal first class types. For example, MVT::v8f32 maps to 2 MVT::v4f32 137869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// with Altivec or SSE1, or 8 promoted MVT::f64 values with the X86 FP stack. 137969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// Similarly, MVT::v2i64 turns into 4 MVT::i32 values with both PPC and X86. 138069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// 138169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// This method returns the number of registers needed, and the VT for each 138269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// register. It also returns the VT and quantity of the intermediate values 138369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// before they are promoted/expanded. 138469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// 138569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramerunsigned TargetLoweringBase::getVectorTypeBreakdown(LLVMContext &Context, EVT VT, 138669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer EVT &IntermediateVT, 138769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer unsigned &NumIntermediates, 138869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer MVT &RegisterVT) const { 138969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer unsigned NumElts = VT.getVectorNumElements(); 139069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 139169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // If there is a wider vector type with the same element type as this one, 139269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // or a promoted vector type that has the same number of elements which 139369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // are wider, then we should convert to that legal vector type. 139469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // This handles things like <2 x float> -> <4 x float> and 139569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // <4 x i1> -> <4 x i32>. 139669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer LegalizeTypeAction TA = getTypeAction(Context, VT); 139769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (NumElts != 1 && (TA == TypeWidenVector || TA == TypePromoteInteger)) { 139869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer EVT RegisterEVT = getTypeToTransformTo(Context, VT); 139969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (isTypeLegal(RegisterEVT)) { 140069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer IntermediateVT = RegisterEVT; 140169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer RegisterVT = RegisterEVT.getSimpleVT(); 140269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer NumIntermediates = 1; 140369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return 1; 140469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 140569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 140669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 140769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Figure out the right, legal destination reg to copy into. 140869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer EVT EltTy = VT.getVectorElementType(); 140969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 141069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer unsigned NumVectorRegs = 1; 141169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 141269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // FIXME: We don't support non-power-of-2-sized vectors for now. Ideally we 141369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // could break down into LHS/RHS like LegalizeDAG does. 141469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (!isPowerOf2_32(NumElts)) { 141569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer NumVectorRegs = NumElts; 141669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer NumElts = 1; 141769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 141869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 141969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Divide the input until we get to a supported size. This will always 142069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // end with a scalar if the target doesn't support vectors. 142169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer while (NumElts > 1 && !isTypeLegal( 142269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer EVT::getVectorVT(Context, EltTy, NumElts))) { 142369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer NumElts >>= 1; 142469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer NumVectorRegs <<= 1; 142569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 142669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 142769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer NumIntermediates = NumVectorRegs; 142869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 142969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer EVT NewVT = EVT::getVectorVT(Context, EltTy, NumElts); 143069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (!isTypeLegal(NewVT)) 143169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer NewVT = EltTy; 143269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer IntermediateVT = NewVT; 143369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 143469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer MVT DestVT = getRegisterType(Context, NewVT); 143569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer RegisterVT = DestVT; 143669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer unsigned NewVTSize = NewVT.getSizeInBits(); 143769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 143869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Convert sizes such as i33 to i64. 143969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (!isPowerOf2_32(NewVTSize)) 144069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer NewVTSize = NextPowerOf2(NewVTSize); 144169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 144269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (EVT(DestVT).bitsLT(NewVT)) // Value is expanded, e.g. i64 -> i16. 144369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return NumVectorRegs*(NewVTSize/DestVT.getSizeInBits()); 144469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 144569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Otherwise, promotion or legal types use the same number of registers as 144669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // the vector decimated to the appropriate level. 144769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return NumVectorRegs; 144869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer} 144969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 145069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// Get the EVTs and ArgFlags collections that represent the legalized return 145169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// type of the given function. This does not require a DAG or a return value, 145269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// and is suitable for use before any DAGs for the function are constructed. 145369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// TODO: Move this out of TargetLowering.cpp. 1454cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainarvoid llvm::GetReturnInfo(Type *ReturnType, AttributeSet attr, 145569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer SmallVectorImpl<ISD::OutputArg> &Outs, 1456cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar const TargetLowering &TLI, const DataLayout &DL) { 145769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer SmallVector<EVT, 4> ValueVTs; 1458cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar ComputeValueVTs(TLI, DL, ReturnType, ValueVTs); 145969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer unsigned NumValues = ValueVTs.size(); 146069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (NumValues == 0) return; 146169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 146269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer for (unsigned j = 0, f = NumValues; j != f; ++j) { 146369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer EVT VT = ValueVTs[j]; 146469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer ISD::NodeType ExtendKind = ISD::ANY_EXTEND; 146569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 146669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (attr.hasAttribute(AttributeSet::ReturnIndex, Attribute::SExt)) 146769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer ExtendKind = ISD::SIGN_EXTEND; 146869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer else if (attr.hasAttribute(AttributeSet::ReturnIndex, Attribute::ZExt)) 146969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer ExtendKind = ISD::ZERO_EXTEND; 147069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 147169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // FIXME: C calling convention requires the return type to be promoted to 147269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // at least 32-bit. But this is not necessary for non-C calling 147369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // conventions. The frontend should mark functions whose return values 147469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // require promoting with signext or zeroext attributes. 147569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (ExtendKind != ISD::ANY_EXTEND && VT.isInteger()) { 147669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer MVT MinVT = TLI.getRegisterType(ReturnType->getContext(), MVT::i32); 147769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (VT.bitsLT(MinVT)) 147869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer VT = MinVT; 147969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 148069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 148169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer unsigned NumParts = TLI.getNumRegisters(ReturnType->getContext(), VT); 148269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer MVT PartVT = TLI.getRegisterType(ReturnType->getContext(), VT); 148369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 148469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // 'inreg' on function refers to return value 148569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer ISD::ArgFlagsTy Flags = ISD::ArgFlagsTy(); 148669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (attr.hasAttribute(AttributeSet::ReturnIndex, Attribute::InReg)) 148769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Flags.setInReg(); 148869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 148969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Propagate extension type if any 149069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (attr.hasAttribute(AttributeSet::ReturnIndex, Attribute::SExt)) 149169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Flags.setSExt(); 149269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer else if (attr.hasAttribute(AttributeSet::ReturnIndex, Attribute::ZExt)) 149369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Flags.setZExt(); 149469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 149569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer for (unsigned i = 0; i < NumParts; ++i) 1496d0716b064744598ba7df33b8b47de0375c450570Tom Stellard Outs.push_back(ISD::OutputArg(Flags, PartVT, VT, /*isFixed=*/true, 0, 0)); 149769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 149869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer} 149969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 150069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// getByValTypeAlignment - Return the desired alignment for ByVal aggregate 150169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// function arguments in the caller parameter area. This is the actual 150269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// alignment, not its logarithm. 1503cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainarunsigned TargetLoweringBase::getByValTypeAlignment(Type *Ty, 1504cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar const DataLayout &DL) const { 1505cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar return DL.getABITypeAlignment(Ty); 1506cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar} 1507cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar 1508cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainarbool TargetLoweringBase::allowsMemoryAccess(LLVMContext &Context, 1509cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar const DataLayout &DL, EVT VT, 1510cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar unsigned AddrSpace, 1511cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar unsigned Alignment, 1512cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar bool *Fast) const { 1513cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar // Check if the specified alignment is sufficient based on the data layout. 1514cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar // TODO: While using the data layout works in practice, a better solution 1515cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar // would be to implement this check directly (make this a virtual function). 1516cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar // For example, the ABI alignment may change based on software platform while 1517cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar // this function should only be affected by hardware implementation. 1518cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar Type *Ty = VT.getTypeForEVT(Context); 1519cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar if (Alignment >= DL.getABITypeAlignment(Ty)) { 1520cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar // Assume that an access that meets the ABI-specified alignment is fast. 1521cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar if (Fast != nullptr) 1522cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar *Fast = true; 1523cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar return true; 1524cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar } 1525cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar 1526cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar // This is a misaligned access. 1527cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar return allowsMisalignedMemoryAccesses(VT, AddrSpace, Alignment, Fast); 152869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer} 152969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 1530cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar 153169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer//===----------------------------------------------------------------------===// 153269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer// TargetTransformInfo Helpers 153369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer//===----------------------------------------------------------------------===// 153469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 153569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramerint TargetLoweringBase::InstructionOpcodeToISD(unsigned Opcode) const { 153669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer enum InstructionOpcodes { 153769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#define HANDLE_INST(NUM, OPCODE, CLASS) OPCODE = NUM, 153869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#define LAST_OTHER_INST(NUM) InstructionOpcodesCount = NUM 153969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer#include "llvm/IR/Instruction.def" 154069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer }; 154169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer switch (static_cast<InstructionOpcodes>(Opcode)) { 154269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case Ret: return 0; 154369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case Br: return 0; 154469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case Switch: return 0; 154569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case IndirectBr: return 0; 154669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case Invoke: return 0; 154769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case Resume: return 0; 154869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case Unreachable: return 0; 1549cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar case CleanupRet: return 0; 1550cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar case CatchRet: return 0; 1551cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar case CatchPad: return 0; 1552cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar case CatchSwitch: return 0; 1553cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar case CleanupPad: return 0; 155469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case Add: return ISD::ADD; 155569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case FAdd: return ISD::FADD; 155669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case Sub: return ISD::SUB; 155769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case FSub: return ISD::FSUB; 155869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case Mul: return ISD::MUL; 155969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case FMul: return ISD::FMUL; 156069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case UDiv: return ISD::UDIV; 1561dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines case SDiv: return ISD::SDIV; 156269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case FDiv: return ISD::FDIV; 156369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case URem: return ISD::UREM; 156469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case SRem: return ISD::SREM; 156569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case FRem: return ISD::FREM; 156669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case Shl: return ISD::SHL; 156769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case LShr: return ISD::SRL; 156869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case AShr: return ISD::SRA; 156969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case And: return ISD::AND; 157069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case Or: return ISD::OR; 157169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case Xor: return ISD::XOR; 157269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case Alloca: return 0; 157369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case Load: return ISD::LOAD; 157469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case Store: return ISD::STORE; 157569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case GetElementPtr: return 0; 157669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case Fence: return 0; 157769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case AtomicCmpXchg: return 0; 157869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case AtomicRMW: return 0; 157969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case Trunc: return ISD::TRUNCATE; 158069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case ZExt: return ISD::ZERO_EXTEND; 158169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case SExt: return ISD::SIGN_EXTEND; 158269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case FPToUI: return ISD::FP_TO_UINT; 158369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case FPToSI: return ISD::FP_TO_SINT; 158469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case UIToFP: return ISD::UINT_TO_FP; 158569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case SIToFP: return ISD::SINT_TO_FP; 158669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case FPTrunc: return ISD::FP_ROUND; 158769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case FPExt: return ISD::FP_EXTEND; 158869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case PtrToInt: return ISD::BITCAST; 158969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case IntToPtr: return ISD::BITCAST; 159069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case BitCast: return ISD::BITCAST; 159159d3ae6cdc4316ad338cd848251f33a236ccb36cMatt Arsenault case AddrSpaceCast: return ISD::ADDRSPACECAST; 159269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case ICmp: return ISD::SETCC; 159369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case FCmp: return ISD::SETCC; 159469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case PHI: return 0; 159569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case Call: return 0; 159669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case Select: return ISD::SELECT; 159769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case UserOp1: return 0; 159869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case UserOp2: return 0; 159969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case VAArg: return 0; 160069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case ExtractElement: return ISD::EXTRACT_VECTOR_ELT; 160169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case InsertElement: return ISD::INSERT_VECTOR_ELT; 160269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case ShuffleVector: return ISD::VECTOR_SHUFFLE; 160369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case ExtractValue: return ISD::MERGE_VALUES; 160469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case InsertValue: return ISD::MERGE_VALUES; 160569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case LandingPad: return 0; 160669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 160769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 160869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer llvm_unreachable("Unknown instruction type encountered!"); 160969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer} 161069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 1611cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainarstd::pair<int, MVT> 1612cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga NainarTargetLoweringBase::getTypeLegalizationCost(const DataLayout &DL, 1613cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar Type *Ty) const { 161469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer LLVMContext &C = Ty->getContext(); 1615cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar EVT MTy = getValueType(DL, Ty); 161669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 1617cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar int Cost = 1; 161869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // We keep legalizing the type until we find a legal kind. We assume that 161969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // the only operation that costs anything is the split. After splitting 162069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // we need to handle two types. 162169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer while (true) { 162269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer LegalizeKind LK = getTypeConversion(C, MTy); 162369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 162469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (LK.first == TypeLegal) 162569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return std::make_pair(Cost, MTy.getSimpleVT()); 162669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 162769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (LK.first == TypeSplitVector || LK.first == TypeExpandInteger) 162869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer Cost *= 2; 162969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 1630cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar // Do not loop with f128 type. 1631cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar if (MTy == LK.second) 1632cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar return std::make_pair(Cost, MTy.getSimpleVT()); 1633cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar 163469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Keep legalizing the type. 163569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer MTy = LK.second; 163669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 163769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer} 163869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 1639cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga NainarValue *TargetLoweringBase::getSafeStackPointerLocation(IRBuilder<> &IRB) const { 1640cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar if (!TM.getTargetTriple().isAndroid()) 1641cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar return nullptr; 1642cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar 1643cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar // Android provides a libc function to retrieve the address of the current 1644cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar // thread's unsafe stack pointer. 1645cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar Module *M = IRB.GetInsertBlock()->getParent()->getParent(); 1646cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar Type *StackPtrTy = Type::getInt8PtrTy(M->getContext()); 1647cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar Value *Fn = M->getOrInsertFunction("__safestack_pointer_address", 1648cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar StackPtrTy->getPointerTo(0), nullptr); 1649cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar return IRB.CreateCall(Fn); 1650cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar} 1651cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar 165269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer//===----------------------------------------------------------------------===// 165369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer// Loop Strength Reduction hooks 165469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer//===----------------------------------------------------------------------===// 165569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 165669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// isLegalAddressingMode - Return true if the addressing mode represented 165769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer/// by AM is legal for this target, for a load/store of the specified type. 1658cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainarbool TargetLoweringBase::isLegalAddressingMode(const DataLayout &DL, 1659cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar const AddrMode &AM, Type *Ty, 16606948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga Nainar unsigned AS) const { 166169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // The default implementation of this implements a conservative RISCy, r+r and 166269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // r+i addr mode. 166369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 166469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Allows a sign-extended 16-bit immediate field. 166569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (AM.BaseOffs <= -(1LL << 16) || AM.BaseOffs >= (1LL << 16)-1) 166669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return false; 166769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 166869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // No global is ever allowed as a base. 166969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (AM.BaseGV) 167069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return false; 167169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 167269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Only support r+r, 167369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer switch (AM.Scale) { 167469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case 0: // "r+i" or just "i", depending on HasBaseReg. 167569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer break; 167669e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case 1: 167769e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (AM.HasBaseReg && AM.BaseOffs) // "r+r+i" is not allowed. 167869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return false; 167969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Otherwise we have r+r or r+i. 168069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer break; 168169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer case 2: 168269e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer if (AM.HasBaseReg || AM.BaseOffs) // 2*r+r or 2*r+i is not allowed. 168369e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return false; 168469e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer // Allow 2*r as r+r. 168569e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer break; 168636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines default: // Don't allow n * r 168736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines return false; 168869e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer } 168969e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer 169069e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer return true; 169169e42dbd006c0afb732067ece7327988b1e24c01Benjamin Kramer} 1692