LLVM  7.0.0
Macros | Functions | Variables
ARMCodeGenPrepare.cpp File Reference

This pass inserts intrinsics to handle small types that would otherwise be promoted during legalization. More...

#include "ARM.h"
#include "ARMSubtarget.h"
#include "ARMTargetMachine.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/TargetPassConfig.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Value.h"
#include "llvm/IR/Verifier.h"
#include "llvm/Pass.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
Include dependency graph for ARMCodeGenPrepare.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "arm-codegenprepare"
 

Functions

static bool isSigned (Value *V)
 Can the given value generate sign bits. More...
 
static bool isSupportedType (Value *V)
 Some instructions can use 8- and 16-bit operands, and we don't need to promote anything larger. More...
 
static bool isSink (Value *V)
 Return true if V will require any promoted values to be truncated for the use to be valid. More...
 
static bool isSource (Value *V)
 Return true if the given value is a leaf that will need to be zext'd. More...
 
static bool isSafeOverflow (Instruction *I)
 Return whether the instruction can be promoted within any modifications to it's operands or result. More...
 
static bool shouldPromote (Value *V)
 
static bool isPromotedResultSafe (Value *V)
 Return whether we can safely mutate V's type to ExtTy without having to be concerned with zero extending or truncation. More...
 
static Intrinsic::ID getNarrowIntrinsic (Instruction *I, unsigned TypeSize)
 Return the intrinsic for the instruction that can perform the same operation but on a narrow type. More...
 
 INITIALIZE_PASS_BEGIN (ARMCodeGenPrepare, DEBUG_TYPE, "ARM IR optimizations", false, false) INITIALIZE_PASS_END(ARMCodeGenPrepare
 

Variables

static cl::opt< bool > DisableCGP ("arm-disable-cgp", cl::Hidden, cl::init(true), cl::desc("Disable ARM specific CodeGenPrepare pass"))
 
static cl::opt< bool > EnableDSP ("arm-enable-scalar-dsp", cl::Hidden, cl::init(false), cl::desc("Use DSP instructions for scalar operations"))
 
static cl::opt< bool > EnableDSPWithImms ("arm-enable-scalar-dsp-imms", cl::Hidden, cl::init(false), cl::desc("Use DSP instructions for scalar operations\ with immediate operands"))
 
 DEBUG_TYPE
 
ARM IR optimizations
 
ARM IR false
 

Detailed Description

This pass inserts intrinsics to handle small types that would otherwise be promoted during legalization.

Here we can manually promote types or insert intrinsics which can handle narrow types that aren't supported by the register classes.

Definition in file ARMCodeGenPrepare.cpp.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "arm-codegenprepare"

Definition at line 40 of file ARMCodeGenPrepare.cpp.

Referenced by getNarrowIntrinsic().

Function Documentation

◆ getNarrowIntrinsic()

static Intrinsic::ID getNarrowIntrinsic ( Instruction *  I,
unsigned  TypeSize 
)
static

Return the intrinsic for the instruction that can perform the same operation but on a narrow type.

This is using the parallel dsp intrinsics on scalar values.

Definition at line 265 of file ARMCodeGenPrepare.cpp.

References llvm::MCID::Add, Arg, llvm::AMDGPU::HSAMD::Kernel::Key::Args, llvm::SetVector< T, Vector, Set >::back(), llvm::SmallPtrSetImplBase::clear(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::dbgs(), DEBUG_TYPE, DisableCGP, llvm::Value::dump(), llvm::dyn_cast(), llvm::SetVector< T, Vector, Set >::empty(), EnableDSP, EnableDSPWithImms, F(), llvm::ConstantInt::get(), llvm::Module::getContext(), llvm::Intrinsic::getDeclaration(), llvm::BasicBlock::getFirstInsertionPt(), llvm::Function::getFunctionType(), llvm::Type::getInt16Ty(), llvm::Type::getInt32Ty(), llvm::Value::getName(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Type::getPrimitiveSizeInBits(), llvm::APInt::getRawData(), llvm::FunctionType::getReturnType(), llvm::ConstantExpr::getSExt(), llvm::TargetMachine::getSubtarget(), llvm::ConstantInt::getType(), llvm::Value::getType(), llvm::ConstantInt::getValue(), llvm::ConstantExpr::getZExt(), I, INITIALIZE_PASS_BEGIN(), llvm::SetVector< T, Vector, Set >::insert(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::isLegalToPromote(), llvm::ConstantInt::isNegative(), isPromotedResultSafe(), isSafeOverflow(), isSigned(), isSink(), isSource(), isSupportedType(), LLVM_DEBUG, llvm_unreachable, llvm::User::operands(), llvm::SetVector< T, Vector, Set >::pop_back(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::report_fatal_error(), runOnFunction(), shouldPromote(), llvm::ARM_MB::ST, llvm::SPII::Store, llvm::SystemZISD::TM, Users, llvm::Value::uses(), and llvm::verifyFunction().

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( ARMCodeGenPrepare  ,
DEBUG_TYPE  ,
"ARM IR optimizations"  ,
false  ,
false   
)

Referenced by getNarrowIntrinsic().

◆ isPromotedResultSafe()

static bool isPromotedResultSafe ( Value *  V)
static

Return whether we can safely mutate V's type to ExtTy without having to be concerned with zero extending or truncation.

Definition at line 244 of file ARMCodeGenPrepare.cpp.

References I, isSafeOverflow(), isSigned(), and isSink().

Referenced by getNarrowIntrinsic().

◆ isSafeOverflow()

static bool isSafeOverflow ( Instruction *  I)
static

Return whether the instruction can be promoted within any modifications to it's operands or result.

Definition at line 187 of file ARMCodeGenPrepare.cpp.

References llvm::MCID::Add, llvm::dbgs(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Instruction::hasNoUnsignedWrap(), llvm::Value::hasOneUse(), LLVM_DEBUG, llvm::User::operands(), and llvm::Value::user_begin().

Referenced by getNarrowIntrinsic(), and isPromotedResultSafe().

◆ isSigned()

static bool isSigned ( Value *  V)
static

◆ isSink()

static bool isSink ( Value *  V)
static

Return true if V will require any promoted values to be truncated for the use to be valid.

Definition at line 148 of file ARMCodeGenPrepare.cpp.

References llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), llvm::MCID::Return, and llvm::SPII::Store.

Referenced by getNarrowIntrinsic(), and isPromotedResultSafe().

◆ isSource()

static bool isSource ( Value *  V)
static

Return true if the given value is a leaf that will need to be zext'd.

Definition at line 162 of file ARMCodeGenPrepare.cpp.

References isSupportedType(), and llvm::SPII::Load.

Referenced by getNarrowIntrinsic().

◆ isSupportedType()

static bool isSupportedType ( Value *  V)
static

Some instructions can use 8- and 16-bit operands, and we don't need to promote anything larger.

We disallow booleans to make life easier when dealing with icmps but allow any other integer that is <= 16 bits. Void types are accepted so we can handle switches.

Definition at line 128 of file ARMCodeGenPrepare.cpp.

References llvm::dyn_cast(), llvm::IntegerType::getBitWidth(), llvm::Value::getType(), and llvm::Type::isVoidTy().

Referenced by getNarrowIntrinsic(), and isSource().

◆ shouldPromote()

static bool shouldPromote ( Value *  V)
static

Definition at line 224 of file ARMCodeGenPrepare.cpp.

References llvm::dyn_cast(), llvm::Value::getType(), and I.

Referenced by getNarrowIntrinsic().

Variable Documentation

◆ DEBUG_TYPE

DEBUG_TYPE

Definition at line 743 of file ARMCodeGenPrepare.cpp.

◆ DisableCGP

cl::opt<bool> DisableCGP("arm-disable-cgp", cl::Hidden, cl::init(true), cl::desc("Disable ARM specific CodeGenPrepare pass"))
static

Referenced by getNarrowIntrinsic().

◆ EnableDSP

cl::opt<bool> EnableDSP("arm-enable-scalar-dsp", cl::Hidden, cl::init(false), cl::desc("Use DSP instructions for scalar operations"))
static

Referenced by getNarrowIntrinsic().

◆ EnableDSPWithImms

cl::opt<bool> EnableDSPWithImms("arm-enable-scalar-dsp-imms", cl::Hidden, cl::init(false), cl::desc("Use DSP instructions for scalar operations\ with immediate operands"))
static

Referenced by getNarrowIntrinsic().

◆ false

ARM IR false

Definition at line 743 of file ARMCodeGenPrepare.cpp.

◆ optimizations

ARM IR optimizations

Definition at line 743 of file ARMCodeGenPrepare.cpp.