LLVM API Documentation

Namespaces | Defines | Functions | Variables
AArch64PromoteConstant.cpp File Reference
#include "AArch64.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InlineAsm.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Module.h"
#include "llvm/Pass.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
Include dependency graph for AArch64PromoteConstant.cpp:

Go to the source code of this file.

Namespaces

namespace  llvm
 

List of target independent CodeGen pass IDs.


Defines

#define DEBUG_TYPE   "aarch64-promote-const"

Functions

 STATISTIC (NumPromoted,"Number of promoted constants")
 STATISTIC (NumPromotedUses,"Number of promoted constants uses")
void llvm::initializeAArch64PromoteConstantPass (PassRegistry &)
 INITIALIZE_PASS_BEGIN (AArch64PromoteConstant,"aarch64-promote-const","AArch64 Promote Constant Pass", false, false) INITIALIZE_PASS_END(AArch64PromoteConstant
static bool isConstantUsingVectorTy (const Type *CstTy)
 Check if the given type uses a vector type.
static bool shouldConvertUse (const Constant *Cst, const Instruction *Instr, unsigned OpIdx)
static bool shouldConvert (const Constant *Cst)

Variables

static cl::opt< boolStress ("aarch64-stress-promote-const", cl::Hidden, cl::desc("Promote all vector constants"))
aarch64 promote const
aarch64 promote AArch64
Promote Constant 
Pass
aarch64 promote AArch64
Promote Constant 
false

Define Documentation

#define DEBUG_TYPE   "aarch64-promote-const"

Definition at line 43 of file AArch64PromoteConstant.cpp.


Function Documentation

INITIALIZE_PASS_BEGIN ( AArch64PromoteConstant  ,
"aarch64-promote-const ,
"AArch64 Promote Constant Pass ,
false  ,
false   
)
static bool isConstantUsingVectorTy ( const Type CstTy) [static]
static bool shouldConvert ( const Constant Cst) [static]

Check if the given Cst should be converted into a load of a global variable initialized with Cst. A constant should be converted if it is likely that the materialization of the constant will be tricky. Thus, we give up on zero or undef values.

Todo:
Currently, accept only vector related types. Also we give up on all simple vector type to keep the existing behavior. Otherwise, we should push here all the check of the lowering of BUILD_VECTOR. By giving up, we lose the potential benefit of merging constant via global merge and the fact that the same constant is stored only once with this method (versus, as many function that uses the constant for the regular approach, even for float). Again, the simplest solution would be to promote every constant and rematerialize them when they are actually cheap to create.

Definition at line 308 of file AArch64PromoteConstant.cpp.

References llvm::Value::getType(), isConstantUsingVectorTy(), llvm::Type::isVectorTy(), llvm::Constant::isZeroValue(), and Stress.

static bool shouldConvertUse ( const Constant Cst,
const Instruction Instr,
unsigned  OpIdx 
) [static]

Check if the given use (Instruction + OpIdx) of Cst should be converted into a load of a global variable initialized with Cst. A use should be converted if it is legal to do so. For instance, it is not legal to turn the mask operand of a shuffle vector into a load of a global variable.

Definition at line 239 of file AArch64PromoteConstant.cpp.

References llvm::dyn_cast(), and llvm::CallInst::getCalledValue().

STATISTIC ( NumPromoted  ,
"Number of promoted constants"   
)
STATISTIC ( NumPromotedUses  ,
"Number of promoted constants uses"   
)

Variable Documentation

aarch64 promote const

Definition at line 213 of file AArch64PromoteConstant.cpp.

aarch64 promote AArch64 Promote Constant false

Definition at line 213 of file AArch64PromoteConstant.cpp.

aarch64 promote AArch64 Promote Constant Pass

Definition at line 213 of file AArch64PromoteConstant.cpp.

cl::opt<bool> Stress("aarch64-stress-promote-const", cl::Hidden, cl::desc("Promote all vector constants")) [static]

Referenced by shouldConvert().