mirror of
https://github.com/RPCS3/llvm.git
synced 2025-05-13 08:56:04 +00:00
Refactor the AddrMode class out of TLI to its own header file.
This class is used by LSR and a number of places in the codegen. This is the first step in de-coupling LSR from TLI, and creating a new interface in between them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165455 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0327244ec6
commit
ad6aedc7d9
41
include/llvm/AddressingMode.h
Normal file
41
include/llvm/AddressingMode.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
//===--------- llvm/AddressingMode.h - Addressing Mode -------*- C++ -*-===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is distributed under the University of Illinois Open Source
|
||||||
|
// License. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
// This file contains addressing mode data structures which are shared
|
||||||
|
// between LSR and a number of places in the codegen.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#ifndef LLVM_ADDRESSING_MODE_H
|
||||||
|
#define LLVM_ADDRESSING_MODE_H
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
namespace llvm {
|
||||||
|
|
||||||
|
class GlobalValue;
|
||||||
|
|
||||||
|
/// AddrMode - This represents an addressing mode of:
|
||||||
|
/// BaseGV + BaseOffs + BaseReg + Scale*ScaleReg
|
||||||
|
/// If BaseGV is null, there is no BaseGV.
|
||||||
|
/// If BaseOffs is zero, there is no base offset.
|
||||||
|
/// If HasBaseReg is false, there is no base register.
|
||||||
|
/// If Scale is zero, there is no ScaleReg. Scale of 1 indicates a reg with
|
||||||
|
/// no scale.
|
||||||
|
///
|
||||||
|
struct AddrMode {
|
||||||
|
GlobalValue *BaseGV;
|
||||||
|
int64_t BaseOffs;
|
||||||
|
bool HasBaseReg;
|
||||||
|
int64_t Scale;
|
||||||
|
AddrMode() : BaseGV(0), BaseOffs(0), HasBaseReg(false), Scale(0) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // End llvm namespace
|
||||||
|
|
||||||
|
#endif
|
@ -22,6 +22,7 @@
|
|||||||
#ifndef LLVM_TARGET_TARGETLOWERING_H
|
#ifndef LLVM_TARGET_TARGETLOWERING_H
|
||||||
#define LLVM_TARGET_TARGETLOWERING_H
|
#define LLVM_TARGET_TARGETLOWERING_H
|
||||||
|
|
||||||
|
#include "llvm/AddressingMode.h"
|
||||||
#include "llvm/CallingConv.h"
|
#include "llvm/CallingConv.h"
|
||||||
#include "llvm/InlineAsm.h"
|
#include "llvm/InlineAsm.h"
|
||||||
#include "llvm/Attributes.h"
|
#include "llvm/Attributes.h"
|
||||||
@ -1632,22 +1633,6 @@ public:
|
|||||||
// Addressing mode description hooks (used by LSR etc).
|
// Addressing mode description hooks (used by LSR etc).
|
||||||
//
|
//
|
||||||
|
|
||||||
/// AddrMode - This represents an addressing mode of:
|
|
||||||
/// BaseGV + BaseOffs + BaseReg + Scale*ScaleReg
|
|
||||||
/// If BaseGV is null, there is no BaseGV.
|
|
||||||
/// If BaseOffs is zero, there is no base offset.
|
|
||||||
/// If HasBaseReg is false, there is no base register.
|
|
||||||
/// If Scale is zero, there is no ScaleReg. Scale of 1 indicates a reg with
|
|
||||||
/// no scale.
|
|
||||||
///
|
|
||||||
struct AddrMode {
|
|
||||||
GlobalValue *BaseGV;
|
|
||||||
int64_t BaseOffs;
|
|
||||||
bool HasBaseReg;
|
|
||||||
int64_t Scale;
|
|
||||||
AddrMode() : BaseGV(0), BaseOffs(0), HasBaseReg(false), Scale(0) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
/// GetAddrModeArguments - CodeGenPrepare sinks address calculations into the
|
/// GetAddrModeArguments - CodeGenPrepare sinks address calculations into the
|
||||||
/// same BB as Load/Store instructions reading the address. This allows as
|
/// same BB as Load/Store instructions reading the address. This allows as
|
||||||
/// much computation as possible to be done in the address mode for that
|
/// much computation as possible to be done in the address mode for that
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#ifndef LLVM_TRANSFORMS_UTILS_ADDRMODEMATCHER_H
|
#ifndef LLVM_TRANSFORMS_UTILS_ADDRMODEMATCHER_H
|
||||||
#define LLVM_TRANSFORMS_UTILS_ADDRMODEMATCHER_H
|
#define LLVM_TRANSFORMS_UTILS_ADDRMODEMATCHER_H
|
||||||
|
|
||||||
|
#include "llvm/AddressingMode.h"
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
#include "llvm/Target/TargetLowering.h"
|
#include "llvm/Target/TargetLowering.h"
|
||||||
|
|
||||||
@ -33,7 +34,7 @@ class raw_ostream;
|
|||||||
|
|
||||||
/// ExtAddrMode - This is an extended version of TargetLowering::AddrMode
|
/// ExtAddrMode - This is an extended version of TargetLowering::AddrMode
|
||||||
/// which holds actual Value*'s for register values.
|
/// which holds actual Value*'s for register values.
|
||||||
struct ExtAddrMode : public TargetLowering::AddrMode {
|
struct ExtAddrMode : public AddrMode {
|
||||||
Value *BaseReg;
|
Value *BaseReg;
|
||||||
Value *ScaledReg;
|
Value *ScaledReg;
|
||||||
ExtAddrMode() : BaseReg(0), ScaledReg(0) {}
|
ExtAddrMode() : BaseReg(0), ScaledReg(0) {}
|
||||||
|
@ -6714,7 +6714,7 @@ static bool canFoldInAddressingMode(SDNode *N, SDNode *Use,
|
|||||||
} else
|
} else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
TargetLowering::AddrMode AM;
|
AddrMode AM;
|
||||||
if (N->getOpcode() == ISD::ADD) {
|
if (N->getOpcode() == ISD::ADD) {
|
||||||
ConstantSDNode *Offset = dyn_cast<ConstantSDNode>(N->getOperand(1));
|
ConstantSDNode *Offset = dyn_cast<ConstantSDNode>(N->getOperand(1));
|
||||||
if (Offset)
|
if (Offset)
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#define DEBUG_TYPE "loop-reduce"
|
#define DEBUG_TYPE "loop-reduce"
|
||||||
#include "llvm/Transforms/Scalar.h"
|
#include "llvm/AddressingMode.h"
|
||||||
#include "llvm/Constants.h"
|
#include "llvm/Constants.h"
|
||||||
#include "llvm/Instructions.h"
|
#include "llvm/Instructions.h"
|
||||||
#include "llvm/IntrinsicInst.h"
|
#include "llvm/IntrinsicInst.h"
|
||||||
@ -64,6 +64,7 @@
|
|||||||
#include "llvm/Analysis/LoopPass.h"
|
#include "llvm/Analysis/LoopPass.h"
|
||||||
#include "llvm/Analysis/ScalarEvolutionExpander.h"
|
#include "llvm/Analysis/ScalarEvolutionExpander.h"
|
||||||
#include "llvm/Assembly/Writer.h"
|
#include "llvm/Assembly/Writer.h"
|
||||||
|
#include "llvm/Transforms/Scalar.h"
|
||||||
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
|
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
|
||||||
#include "llvm/Transforms/Utils/Local.h"
|
#include "llvm/Transforms/Utils/Local.h"
|
||||||
#include "llvm/ADT/SmallBitVector.h"
|
#include "llvm/ADT/SmallBitVector.h"
|
||||||
@ -225,7 +226,7 @@ namespace {
|
|||||||
struct Formula {
|
struct Formula {
|
||||||
/// AM - This is used to represent complex addressing, as well as other kinds
|
/// AM - This is used to represent complex addressing, as well as other kinds
|
||||||
/// of interesting uses.
|
/// of interesting uses.
|
||||||
TargetLowering::AddrMode AM;
|
AddrMode AM;
|
||||||
|
|
||||||
/// BaseRegs - The list of "base" registers for this use. When this is
|
/// BaseRegs - The list of "base" registers for this use. When this is
|
||||||
/// non-empty, AM.HasBaseReg should be set to true.
|
/// non-empty, AM.HasBaseReg should be set to true.
|
||||||
@ -1269,7 +1270,7 @@ void LSRUse::dump() const {
|
|||||||
/// isLegalUse - Test whether the use described by AM is "legal", meaning it can
|
/// isLegalUse - Test whether the use described by AM is "legal", meaning it can
|
||||||
/// be completely folded into the user instruction at isel time. This includes
|
/// be completely folded into the user instruction at isel time. This includes
|
||||||
/// address-mode folding and special icmp tricks.
|
/// address-mode folding and special icmp tricks.
|
||||||
static bool isLegalUse(const TargetLowering::AddrMode &AM,
|
static bool isLegalUse(const AddrMode &AM,
|
||||||
LSRUse::KindType Kind, Type *AccessTy,
|
LSRUse::KindType Kind, Type *AccessTy,
|
||||||
const TargetLowering *TLI) {
|
const TargetLowering *TLI) {
|
||||||
switch (Kind) {
|
switch (Kind) {
|
||||||
@ -1326,7 +1327,7 @@ static bool isLegalUse(const TargetLowering::AddrMode &AM,
|
|||||||
llvm_unreachable("Invalid LSRUse Kind!");
|
llvm_unreachable("Invalid LSRUse Kind!");
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isLegalUse(TargetLowering::AddrMode AM,
|
static bool isLegalUse(AddrMode AM,
|
||||||
int64_t MinOffset, int64_t MaxOffset,
|
int64_t MinOffset, int64_t MaxOffset,
|
||||||
LSRUse::KindType Kind, Type *AccessTy,
|
LSRUse::KindType Kind, Type *AccessTy,
|
||||||
const TargetLowering *TLI) {
|
const TargetLowering *TLI) {
|
||||||
@ -1357,7 +1358,7 @@ static bool isAlwaysFoldable(int64_t BaseOffs,
|
|||||||
|
|
||||||
// Conservatively, create an address with an immediate and a
|
// Conservatively, create an address with an immediate and a
|
||||||
// base and a scale.
|
// base and a scale.
|
||||||
TargetLowering::AddrMode AM;
|
AddrMode AM;
|
||||||
AM.BaseOffs = BaseOffs;
|
AM.BaseOffs = BaseOffs;
|
||||||
AM.BaseGV = BaseGV;
|
AM.BaseGV = BaseGV;
|
||||||
AM.HasBaseReg = HasBaseReg;
|
AM.HasBaseReg = HasBaseReg;
|
||||||
@ -1395,7 +1396,7 @@ static bool isAlwaysFoldable(const SCEV *S,
|
|||||||
|
|
||||||
// Conservatively, create an address with an immediate and a
|
// Conservatively, create an address with an immediate and a
|
||||||
// base and a scale.
|
// base and a scale.
|
||||||
TargetLowering::AddrMode AM;
|
AddrMode AM;
|
||||||
AM.BaseOffs = BaseOffs;
|
AM.BaseOffs = BaseOffs;
|
||||||
AM.BaseGV = BaseGV;
|
AM.BaseGV = BaseGV;
|
||||||
AM.HasBaseReg = HasBaseReg;
|
AM.HasBaseReg = HasBaseReg;
|
||||||
@ -2020,7 +2021,7 @@ LSRInstance::OptimizeLoopTermCond() {
|
|||||||
goto decline_post_inc;
|
goto decline_post_inc;
|
||||||
// Check for possible scaled-address reuse.
|
// Check for possible scaled-address reuse.
|
||||||
Type *AccessTy = getAccessType(UI->getUser());
|
Type *AccessTy = getAccessType(UI->getUser());
|
||||||
TargetLowering::AddrMode AM;
|
AddrMode AM;
|
||||||
AM.Scale = C->getSExtValue();
|
AM.Scale = C->getSExtValue();
|
||||||
if (TLI->isLegalAddressingMode(AM, AccessTy))
|
if (TLI->isLegalAddressingMode(AM, AccessTy))
|
||||||
goto decline_post_inc;
|
goto decline_post_inc;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user