mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-12 13:38:21 +00:00
add a hook to allow targets to hack on inline asms to lower them to llvm
when they want to. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31997 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -20,9 +20,8 @@
|
|||||||
#include "llvm/Support/DataTypes.h"
|
#include "llvm/Support/DataTypes.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
// Forward declaration.
|
|
||||||
class TargetMachine;
|
class TargetMachine;
|
||||||
|
class CallInst;
|
||||||
|
|
||||||
/// TargetAsmInfo - This class is intended to be used as a base class for asm
|
/// TargetAsmInfo - This class is intended to be used as a base class for asm
|
||||||
/// properties and features specific to the target.
|
/// properties and features specific to the target.
|
||||||
@ -286,8 +285,15 @@ namespace llvm {
|
|||||||
/// Measure the specified inline asm to determine an approximation of its
|
/// Measure the specified inline asm to determine an approximation of its
|
||||||
/// length.
|
/// length.
|
||||||
unsigned getInlineAsmLength(const char *Str) const;
|
unsigned getInlineAsmLength(const char *Str) const;
|
||||||
|
|
||||||
|
/// ExpandInlineAsm - This hook allows the target to expand an inline asm
|
||||||
|
/// call to be explicit llvm code if it wants to. This is useful for
|
||||||
|
/// turning simple inline asms into LLVM intrinsics, which gives the
|
||||||
|
/// compiler more information about the behavior of the code.
|
||||||
|
virtual bool ExpandInlineAsm(CallInst *CI) const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Accessors.
|
// Accessors.
|
||||||
//
|
//
|
||||||
const char *getTextSection() const {
|
const char *getTextSection() const {
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "llvm/CodeGen/SelectionDAG.h"
|
#include "llvm/CodeGen/SelectionDAG.h"
|
||||||
#include "llvm/CodeGen/SSARegMap.h"
|
#include "llvm/CodeGen/SSARegMap.h"
|
||||||
#include "llvm/Target/MRegisterInfo.h"
|
#include "llvm/Target/MRegisterInfo.h"
|
||||||
|
#include "llvm/Target/TargetAsmInfo.h"
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
#include "llvm/Target/TargetFrameInfo.h"
|
#include "llvm/Target/TargetFrameInfo.h"
|
||||||
#include "llvm/Target/TargetInstrInfo.h"
|
#include "llvm/Target/TargetInstrInfo.h"
|
||||||
@ -3780,7 +3781,17 @@ bool SelectionDAGISel::runOnFunction(Function &Fn) {
|
|||||||
|
|
||||||
for (BasicBlock::iterator BBI = BB->begin(), E = BB->end(); BBI != E; ) {
|
for (BasicBlock::iterator BBI = BB->begin(), E = BB->end(); BBI != E; ) {
|
||||||
Instruction *I = BBI++;
|
Instruction *I = BBI++;
|
||||||
if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(I)) {
|
|
||||||
|
if (CallInst *CI = dyn_cast<CallInst>(I)) {
|
||||||
|
// If we found an inline asm expession, and if the target knows how to
|
||||||
|
// lower it to normal LLVM code, do so now.
|
||||||
|
if (isa<InlineAsm>(CI->getCalledValue()))
|
||||||
|
if (const TargetAsmInfo *TAI =
|
||||||
|
TLI.getTargetMachine().getTargetAsmInfo()) {
|
||||||
|
if (TAI->ExpandInlineAsm(CI))
|
||||||
|
BBI = BB->begin();
|
||||||
|
}
|
||||||
|
} else if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(I)) {
|
||||||
MadeChange |= OptimizeGEPExpression(GEPI, TLI.getTargetData());
|
MadeChange |= OptimizeGEPExpression(GEPI, TLI.getTargetData());
|
||||||
} else if (CastInst *CI = dyn_cast<CastInst>(I)) {
|
} else if (CastInst *CI = dyn_cast<CastInst>(I)) {
|
||||||
// If the source of the cast is a constant, then this should have
|
// If the source of the cast is a constant, then this should have
|
||||||
@ -4004,6 +4015,7 @@ void SelectionDAGISel::BuildSelectionDAG(SelectionDAG &DAG, BasicBlock *LLVMBB,
|
|||||||
|
|
||||||
unsigned Reg;
|
unsigned Reg;
|
||||||
Value *PHIOp = PN->getIncomingValueForBlock(LLVMBB);
|
Value *PHIOp = PN->getIncomingValueForBlock(LLVMBB);
|
||||||
|
|
||||||
if (Constant *C = dyn_cast<Constant>(PHIOp)) {
|
if (Constant *C = dyn_cast<Constant>(PHIOp)) {
|
||||||
unsigned &RegOut = ConstantsOut[C];
|
unsigned &RegOut = ConstantsOut[C];
|
||||||
if (RegOut == 0) {
|
if (RegOut == 0) {
|
||||||
|
Reference in New Issue
Block a user