2005-02-05 10:24:26 +08:00
|
|
|
//===- AlphaISelPattern.cpp - A pattern matching inst selector for Alpha --===//
|
2005-01-23 07:41:55 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines a pattern matching instruction selector for Alpha.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "Alpha.h"
|
|
|
|
#include "AlphaRegisterInfo.h"
|
|
|
|
#include "llvm/Constants.h" // FIXME: REMOVE
|
|
|
|
#include "llvm/Function.h"
|
|
|
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
|
|
|
#include "llvm/CodeGen/MachineConstantPool.h" // FIXME: REMOVE
|
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
|
|
|
#include "llvm/CodeGen/MachineFrameInfo.h"
|
|
|
|
#include "llvm/CodeGen/SelectionDAG.h"
|
|
|
|
#include "llvm/CodeGen/SelectionDAGISel.h"
|
|
|
|
#include "llvm/CodeGen/SSARegMap.h"
|
|
|
|
#include "llvm/Target/TargetData.h"
|
|
|
|
#include "llvm/Target/TargetLowering.h"
|
|
|
|
#include "llvm/Support/MathExtras.h"
|
|
|
|
#include "llvm/ADT/Statistic.h"
|
2005-02-23 05:59:48 +08:00
|
|
|
#include "llvm/Support/Debug.h"
|
2005-01-23 07:41:55 +08:00
|
|
|
#include <set>
|
2005-01-30 08:35:27 +08:00
|
|
|
#include <algorithm>
|
2005-01-23 07:41:55 +08:00
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// AlphaTargetLowering - Alpha Implementation of the TargetLowering interface
|
|
|
|
namespace {
|
|
|
|
class AlphaTargetLowering : public TargetLowering {
|
|
|
|
int VarArgsFrameIndex; // FrameIndex for start of varargs area.
|
|
|
|
unsigned GP; //GOT vreg
|
|
|
|
public:
|
|
|
|
AlphaTargetLowering(TargetMachine &TM) : TargetLowering(TM) {
|
|
|
|
// Set up the TargetLowering object.
|
2005-01-27 11:49:45 +08:00
|
|
|
//I am having problems with shr n ubyte 1
|
2005-02-03 01:00:21 +08:00
|
|
|
setShiftAmountType(MVT::i64);
|
|
|
|
setSetCCResultType(MVT::i64);
|
2005-01-27 11:49:45 +08:00
|
|
|
|
2005-01-23 07:41:55 +08:00
|
|
|
addRegisterClass(MVT::i64, Alpha::GPRCRegisterClass);
|
|
|
|
addRegisterClass(MVT::f64, Alpha::FPRCRegisterClass);
|
2005-01-27 11:49:45 +08:00
|
|
|
addRegisterClass(MVT::f32, Alpha::FPRCRegisterClass);
|
2005-02-10 14:25:22 +08:00
|
|
|
|
2005-01-27 15:50:35 +08:00
|
|
|
setOperationAction(ISD::EXTLOAD , MVT::i1 , Promote);
|
2005-03-05 04:09:23 +08:00
|
|
|
setOperationAction(ISD::EXTLOAD , MVT::f32 , Promote);
|
2005-01-25 08:35:34 +08:00
|
|
|
|
2005-01-29 07:17:54 +08:00
|
|
|
setOperationAction(ISD::ZEXTLOAD , MVT::i1 , Expand);
|
2005-01-23 07:41:55 +08:00
|
|
|
setOperationAction(ISD::ZEXTLOAD , MVT::i32 , Expand);
|
2005-01-25 08:35:34 +08:00
|
|
|
|
2005-01-29 07:17:54 +08:00
|
|
|
setOperationAction(ISD::SEXTLOAD , MVT::i1 , Expand);
|
2005-01-23 07:41:55 +08:00
|
|
|
setOperationAction(ISD::SEXTLOAD , MVT::i8 , Expand);
|
|
|
|
setOperationAction(ISD::SEXTLOAD , MVT::i16 , Expand);
|
|
|
|
|
2005-02-05 21:19:12 +08:00
|
|
|
setOperationAction(ISD::SREM , MVT::f32 , Expand);
|
|
|
|
setOperationAction(ISD::SREM , MVT::f64 , Expand);
|
2005-01-26 09:24:38 +08:00
|
|
|
|
2005-02-02 13:49:42 +08:00
|
|
|
setOperationAction(ISD::MEMMOVE , MVT::Other, Expand);
|
2005-02-05 21:19:12 +08:00
|
|
|
setOperationAction(ISD::MEMSET , MVT::Other, Expand);
|
|
|
|
setOperationAction(ISD::MEMCPY , MVT::Other, Expand);
|
|
|
|
|
2005-03-05 04:09:23 +08:00
|
|
|
//Doesn't work yet
|
2005-02-14 13:41:43 +08:00
|
|
|
setOperationAction(ISD::SETCC , MVT::f32, Promote);
|
|
|
|
|
2005-02-10 14:25:22 +08:00
|
|
|
computeRegisterProperties();
|
2005-01-23 07:41:55 +08:00
|
|
|
|
2005-02-10 14:25:22 +08:00
|
|
|
addLegalFPImmediate(+0.0); //F31
|
|
|
|
addLegalFPImmediate(-0.0); //-F31
|
2005-01-23 07:41:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// LowerArguments - This hook must be implemented to indicate how we should
|
|
|
|
/// lower the arguments for the specified function, into the specified DAG.
|
|
|
|
virtual std::vector<SDOperand>
|
|
|
|
LowerArguments(Function &F, SelectionDAG &DAG);
|
2005-02-10 14:25:22 +08:00
|
|
|
|
2005-01-23 07:41:55 +08:00
|
|
|
/// LowerCallTo - This hook lowers an abstract call to a function into an
|
|
|
|
/// actual call.
|
|
|
|
virtual std::pair<SDOperand, SDOperand>
|
2005-03-26 09:29:23 +08:00
|
|
|
LowerCallTo(SDOperand Chain, const Type *RetTy, bool isVarArg,
|
|
|
|
SDOperand Callee, ArgListTy &Args, SelectionDAG &DAG);
|
2005-02-10 14:25:22 +08:00
|
|
|
|
2005-01-23 07:41:55 +08:00
|
|
|
virtual std::pair<SDOperand, SDOperand>
|
|
|
|
LowerVAStart(SDOperand Chain, SelectionDAG &DAG);
|
2005-02-10 14:25:22 +08:00
|
|
|
|
2005-01-23 07:41:55 +08:00
|
|
|
virtual std::pair<SDOperand,SDOperand>
|
|
|
|
LowerVAArgNext(bool isVANext, SDOperand Chain, SDOperand VAList,
|
|
|
|
const Type *ArgTy, SelectionDAG &DAG);
|
|
|
|
|
|
|
|
virtual std::pair<SDOperand, SDOperand>
|
|
|
|
LowerFrameReturnAddress(bool isFrameAddr, SDOperand Chain, unsigned Depth,
|
|
|
|
SelectionDAG &DAG);
|
|
|
|
|
|
|
|
void restoreGP(MachineBasicBlock* BB)
|
|
|
|
{
|
|
|
|
BuildMI(BB, Alpha::BIS, 2, Alpha::R29).addReg(GP).addReg(GP);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
//http://www.cs.arizona.edu/computer.help/policy/DIGITAL_unix/AA-PY8AC-TET1_html/callCH3.html#BLOCK21
|
|
|
|
|
|
|
|
//For now, just use variable size stack frame format
|
|
|
|
|
|
|
|
//In a standard call, the first six items are passed in registers $16
|
|
|
|
//- $21 and/or registers $f16 - $f21. (See Section 4.1.2 for details
|
|
|
|
//of argument-to-register correspondence.) The remaining items are
|
|
|
|
//collected in a memory argument list that is a naturally aligned
|
|
|
|
//array of quadwords. In a standard call, this list, if present, must
|
|
|
|
//be passed at 0(SP).
|
|
|
|
//7 ... n 0(SP) ... (n-7)*8(SP)
|
|
|
|
|
|
|
|
std::vector<SDOperand>
|
|
|
|
AlphaTargetLowering::LowerArguments(Function &F, SelectionDAG &DAG)
|
|
|
|
{
|
|
|
|
std::vector<SDOperand> ArgValues;
|
|
|
|
|
|
|
|
// //#define FP $15
|
|
|
|
// //#define RA $26
|
|
|
|
// //#define PV $27
|
|
|
|
// //#define GP $29
|
|
|
|
// //#define SP $30
|
|
|
|
|
|
|
|
// assert(0 && "TODO");
|
|
|
|
MachineFunction &MF = DAG.getMachineFunction();
|
2005-02-07 13:07:00 +08:00
|
|
|
MachineFrameInfo*MFI = MF.getFrameInfo();
|
2005-01-23 07:41:55 +08:00
|
|
|
|
|
|
|
GP = MF.getSSARegMap()->createVirtualRegister(getRegClassFor(MVT::i64));
|
|
|
|
MachineBasicBlock& BB = MF.front();
|
|
|
|
|
|
|
|
//Handle the return address
|
|
|
|
//BuildMI(&BB, Alpha::IDEF, 0, Alpha::R26);
|
|
|
|
|
2005-01-27 05:54:09 +08:00
|
|
|
unsigned args_int[] = {Alpha::R16, Alpha::R17, Alpha::R18,
|
|
|
|
Alpha::R19, Alpha::R20, Alpha::R21};
|
|
|
|
unsigned args_float[] = {Alpha::F16, Alpha::F17, Alpha::F18,
|
|
|
|
Alpha::F19, Alpha::F20, Alpha::F21};
|
2005-02-07 05:07:31 +08:00
|
|
|
unsigned argVreg[6];
|
|
|
|
unsigned argPreg[6];
|
|
|
|
unsigned argOpc[6];
|
|
|
|
|
2005-01-23 07:41:55 +08:00
|
|
|
int count = 0;
|
2005-02-07 05:07:31 +08:00
|
|
|
|
2005-03-15 12:54:21 +08:00
|
|
|
for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end(); I != E; ++I)
|
2005-02-10 14:25:22 +08:00
|
|
|
{
|
|
|
|
SDOperand newroot, argt;
|
|
|
|
if (count < 6) {
|
|
|
|
switch (getValueType(I->getType())) {
|
|
|
|
default:
|
|
|
|
std::cerr << "Unknown Type " << getValueType(I->getType()) << "\n";
|
|
|
|
abort();
|
|
|
|
case MVT::f64:
|
|
|
|
case MVT::f32:
|
|
|
|
BuildMI(&BB, Alpha::IDEF, 0, args_float[count]);
|
|
|
|
argVreg[count] =
|
|
|
|
MF.getSSARegMap()->createVirtualRegister(
|
2005-02-23 05:59:48 +08:00
|
|
|
getRegClassFor(getValueType(I->getType())));
|
2005-02-10 14:25:22 +08:00
|
|
|
argPreg[count] = args_float[count];
|
|
|
|
argOpc[count] = Alpha::CPYS;
|
|
|
|
argt = newroot = DAG.getCopyFromReg(argVreg[count],
|
|
|
|
getValueType(I->getType()),
|
|
|
|
DAG.getRoot());
|
|
|
|
break;
|
|
|
|
case MVT::i1:
|
|
|
|
case MVT::i8:
|
|
|
|
case MVT::i16:
|
|
|
|
case MVT::i32:
|
|
|
|
case MVT::i64:
|
|
|
|
BuildMI(&BB, Alpha::IDEF, 0, args_int[count]);
|
|
|
|
argVreg[count] =
|
|
|
|
MF.getSSARegMap()->createVirtualRegister(getRegClassFor(MVT::i64));
|
|
|
|
argPreg[count] = args_int[count];
|
|
|
|
argOpc[count] = Alpha::BIS;
|
|
|
|
argt = newroot =
|
|
|
|
DAG.getCopyFromReg(argVreg[count], MVT::i64, DAG.getRoot());
|
|
|
|
if (getValueType(I->getType()) != MVT::i64)
|
|
|
|
argt =
|
|
|
|
DAG.getNode(ISD::TRUNCATE, getValueType(I->getType()), newroot);
|
|
|
|
break;
|
2005-01-28 14:57:18 +08:00
|
|
|
}
|
2005-02-10 14:25:22 +08:00
|
|
|
} else { //more args
|
|
|
|
// Create the frame index object for this incoming parameter...
|
|
|
|
int FI = MFI->CreateFixedObject(8, 8 * (count - 6));
|
|
|
|
|
|
|
|
// Create the SelectionDAG nodes corresponding to a load
|
|
|
|
//from this parameter
|
|
|
|
SDOperand FIN = DAG.getFrameIndex(FI, MVT::i64);
|
|
|
|
argt = newroot = DAG.getLoad(getValueType(I->getType()),
|
|
|
|
DAG.getEntryNode(), FIN);
|
2005-01-23 07:41:55 +08:00
|
|
|
}
|
2005-02-23 05:59:48 +08:00
|
|
|
++count;
|
2005-02-10 14:25:22 +08:00
|
|
|
DAG.setRoot(newroot.getValue(1));
|
|
|
|
ArgValues.push_back(argt);
|
|
|
|
}
|
2005-01-23 07:41:55 +08:00
|
|
|
|
|
|
|
BuildMI(&BB, Alpha::IDEF, 0, Alpha::R29);
|
|
|
|
BuildMI(&BB, Alpha::BIS, 2, GP).addReg(Alpha::R29).addReg(Alpha::R29);
|
2005-02-23 05:59:48 +08:00
|
|
|
for (int i = 0; i < count && i < 6; ++i) {
|
2005-02-10 14:25:22 +08:00
|
|
|
BuildMI(&BB, argOpc[i], 2,
|
|
|
|
argVreg[i]).addReg(argPreg[i]).addReg(argPreg[i]);
|
|
|
|
}
|
2005-01-28 14:57:18 +08:00
|
|
|
|
2005-01-23 07:41:55 +08:00
|
|
|
return ArgValues;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::pair<SDOperand, SDOperand>
|
|
|
|
AlphaTargetLowering::LowerCallTo(SDOperand Chain,
|
2005-03-26 09:29:23 +08:00
|
|
|
const Type *RetTy, bool isVarArg,
|
|
|
|
SDOperand Callee, ArgListTy &Args, SelectionDAG &DAG) {
|
2005-01-23 07:41:55 +08:00
|
|
|
int NumBytes = 0;
|
2005-01-30 08:35:27 +08:00
|
|
|
if (Args.size() > 6)
|
|
|
|
NumBytes = (Args.size() - 6) * 8;
|
|
|
|
|
2005-01-23 07:41:55 +08:00
|
|
|
Chain = DAG.getNode(ISD::ADJCALLSTACKDOWN, MVT::Other, Chain,
|
|
|
|
DAG.getConstant(NumBytes, getPointerTy()));
|
|
|
|
std::vector<SDOperand> args_to_use;
|
|
|
|
for (unsigned i = 0, e = Args.size(); i != e; ++i)
|
2005-02-10 14:25:22 +08:00
|
|
|
{
|
|
|
|
switch (getValueType(Args[i].second)) {
|
|
|
|
default: assert(0 && "Unexpected ValueType for argument!");
|
|
|
|
case MVT::i1:
|
|
|
|
case MVT::i8:
|
|
|
|
case MVT::i16:
|
|
|
|
case MVT::i32:
|
|
|
|
// Promote the integer to 64 bits. If the input type is signed use a
|
|
|
|
// sign extend, otherwise use a zero extend.
|
|
|
|
if (Args[i].second->isSigned())
|
|
|
|
Args[i].first = DAG.getNode(ISD::SIGN_EXTEND, MVT::i64, Args[i].first);
|
|
|
|
else
|
|
|
|
Args[i].first = DAG.getNode(ISD::ZERO_EXTEND, MVT::i64, Args[i].first);
|
|
|
|
break;
|
|
|
|
case MVT::i64:
|
|
|
|
case MVT::f64:
|
|
|
|
case MVT::f32:
|
|
|
|
break;
|
2005-01-23 07:41:55 +08:00
|
|
|
}
|
2005-02-10 14:25:22 +08:00
|
|
|
args_to_use.push_back(Args[i].first);
|
|
|
|
}
|
2005-01-28 14:57:18 +08:00
|
|
|
|
2005-01-23 07:41:55 +08:00
|
|
|
std::vector<MVT::ValueType> RetVals;
|
|
|
|
MVT::ValueType RetTyVT = getValueType(RetTy);
|
|
|
|
if (RetTyVT != MVT::isVoid)
|
|
|
|
RetVals.push_back(RetTyVT);
|
|
|
|
RetVals.push_back(MVT::Other);
|
|
|
|
|
2005-02-10 14:25:22 +08:00
|
|
|
SDOperand TheCall = SDOperand(DAG.getCall(RetVals,
|
|
|
|
Chain, Callee, args_to_use), 0);
|
2005-01-23 07:41:55 +08:00
|
|
|
Chain = TheCall.getValue(RetTyVT != MVT::isVoid);
|
|
|
|
Chain = DAG.getNode(ISD::ADJCALLSTACKUP, MVT::Other, Chain,
|
|
|
|
DAG.getConstant(NumBytes, getPointerTy()));
|
2005-02-10 14:25:22 +08:00
|
|
|
return std::make_pair(TheCall, Chain);
|
2005-01-23 07:41:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::pair<SDOperand, SDOperand>
|
|
|
|
AlphaTargetLowering::LowerVAStart(SDOperand Chain, SelectionDAG &DAG) {
|
|
|
|
//vastart just returns the address of the VarArgsFrameIndex slot.
|
|
|
|
return std::make_pair(DAG.getFrameIndex(VarArgsFrameIndex, MVT::i64), Chain);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::pair<SDOperand,SDOperand> AlphaTargetLowering::
|
|
|
|
LowerVAArgNext(bool isVANext, SDOperand Chain, SDOperand VAList,
|
2005-02-10 14:25:22 +08:00
|
|
|
const Type *ArgTy, SelectionDAG &DAG) {
|
2005-01-23 07:41:55 +08:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::pair<SDOperand, SDOperand> AlphaTargetLowering::
|
|
|
|
LowerFrameReturnAddress(bool isFrameAddress, SDOperand Chain, unsigned Depth,
|
|
|
|
SelectionDAG &DAG) {
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2005-02-10 14:25:22 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
/// ISel - Alpha specific code to select Alpha machine instructions for
|
|
|
|
/// SelectionDAG operations.
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
class ISel : public SelectionDAGISel {
|
|
|
|
|
|
|
|
/// AlphaLowering - This object fully describes how to lower LLVM code to an
|
|
|
|
/// Alpha-specific SelectionDAG.
|
|
|
|
AlphaTargetLowering AlphaLowering;
|
|
|
|
|
|
|
|
|
|
|
|
/// ExprMap - As shared expressions are codegen'd, we keep track of which
|
|
|
|
/// vreg the value is produced in, so we only emit one copy of each compiled
|
|
|
|
/// tree.
|
|
|
|
static const unsigned notIn = (unsigned)(-1);
|
|
|
|
std::map<SDOperand, unsigned> ExprMap;
|
|
|
|
|
|
|
|
//CCInvMap sometimes (SetNE) we have the inverse CC code for free
|
|
|
|
std::map<SDOperand, unsigned> CCInvMap;
|
|
|
|
|
|
|
|
public:
|
|
|
|
ISel(TargetMachine &TM) : SelectionDAGISel(AlphaLowering), AlphaLowering(TM)
|
|
|
|
{}
|
|
|
|
|
|
|
|
/// InstructionSelectBasicBlock - This callback is invoked by
|
|
|
|
/// SelectionDAGISel when it has created a SelectionDAG for us to codegen.
|
|
|
|
virtual void InstructionSelectBasicBlock(SelectionDAG &DAG) {
|
2005-02-23 05:59:48 +08:00
|
|
|
DEBUG(BB->dump());
|
2005-02-10 14:25:22 +08:00
|
|
|
// Codegen the basic block.
|
|
|
|
Select(DAG.getRoot());
|
|
|
|
|
|
|
|
// Clear state used for selection.
|
|
|
|
ExprMap.clear();
|
|
|
|
CCInvMap.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned SelectExpr(SDOperand N);
|
|
|
|
unsigned SelectExprFP(SDOperand N, unsigned Result);
|
|
|
|
void Select(SDOperand N);
|
|
|
|
|
|
|
|
void SelectAddr(SDOperand N, unsigned& Reg, long& offset);
|
|
|
|
void SelectBranchCC(SDOperand N);
|
|
|
|
};
|
2005-01-23 07:41:55 +08:00
|
|
|
}
|
|
|
|
|
2005-03-12 01:48:05 +08:00
|
|
|
//These describe LDAx
|
2005-03-30 03:24:04 +08:00
|
|
|
static const int IMM_LOW = -32768;
|
|
|
|
static const int IMM_HIGH = 32767;
|
2005-03-12 01:48:05 +08:00
|
|
|
static const int IMM_MULT = 65536;
|
|
|
|
|
|
|
|
static long getUpper16(long l)
|
|
|
|
{
|
|
|
|
long y = l / IMM_MULT;
|
|
|
|
if (l % IMM_MULT > IMM_HIGH)
|
|
|
|
++y;
|
|
|
|
return y;
|
|
|
|
}
|
|
|
|
|
|
|
|
static long getLower16(long l)
|
|
|
|
{
|
|
|
|
long h = getUpper16(l);
|
|
|
|
return l - h * IMM_MULT;
|
|
|
|
}
|
|
|
|
|
2005-02-07 00:22:15 +08:00
|
|
|
static unsigned GetSymVersion(unsigned opcode)
|
|
|
|
{
|
|
|
|
switch (opcode) {
|
|
|
|
default: assert(0 && "unknown load or store"); return 0;
|
|
|
|
case Alpha::LDQ: return Alpha::LDQ_SYM;
|
|
|
|
case Alpha::LDS: return Alpha::LDS_SYM;
|
|
|
|
case Alpha::LDT: return Alpha::LDT_SYM;
|
|
|
|
case Alpha::LDL: return Alpha::LDL_SYM;
|
|
|
|
case Alpha::LDBU: return Alpha::LDBU_SYM;
|
|
|
|
case Alpha::LDWU: return Alpha::LDWU_SYM;
|
|
|
|
case Alpha::LDW: return Alpha::LDW_SYM;
|
|
|
|
case Alpha::LDB: return Alpha::LDB_SYM;
|
|
|
|
case Alpha::STQ: return Alpha::STQ_SYM;
|
|
|
|
case Alpha::STS: return Alpha::STS_SYM;
|
|
|
|
case Alpha::STT: return Alpha::STT_SYM;
|
|
|
|
case Alpha::STL: return Alpha::STL_SYM;
|
|
|
|
case Alpha::STW: return Alpha::STW_SYM;
|
|
|
|
case Alpha::STB: return Alpha::STB_SYM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-06 23:40:40 +08:00
|
|
|
//Check to see if the load is a constant offset from a base register
|
|
|
|
void ISel::SelectAddr(SDOperand N, unsigned& Reg, long& offset)
|
|
|
|
{
|
|
|
|
unsigned opcode = N.getOpcode();
|
|
|
|
if (opcode == ISD::ADD) {
|
2005-02-10 14:25:22 +08:00
|
|
|
if(N.getOperand(1).getOpcode() == ISD::Constant &&
|
|
|
|
cast<ConstantSDNode>(N.getOperand(1))->getValue() <= 32767)
|
|
|
|
{ //Normal imm add
|
|
|
|
Reg = SelectExpr(N.getOperand(0));
|
|
|
|
offset = cast<ConstantSDNode>(N.getOperand(1))->getValue();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if(N.getOperand(0).getOpcode() == ISD::Constant &&
|
|
|
|
cast<ConstantSDNode>(N.getOperand(0))->getValue() <= 32767)
|
|
|
|
{
|
|
|
|
Reg = SelectExpr(N.getOperand(1));
|
|
|
|
offset = cast<ConstantSDNode>(N.getOperand(0))->getValue();
|
|
|
|
return;
|
|
|
|
}
|
2005-02-06 23:40:40 +08:00
|
|
|
}
|
|
|
|
Reg = SelectExpr(N);
|
|
|
|
offset = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-02-08 08:40:03 +08:00
|
|
|
void ISel::SelectBranchCC(SDOperand N)
|
|
|
|
{
|
|
|
|
assert(N.getOpcode() == ISD::BRCOND && "Not a BranchCC???");
|
2005-02-10 14:25:22 +08:00
|
|
|
MachineBasicBlock *Dest =
|
|
|
|
cast<BasicBlockSDNode>(N.getOperand(2))->getBasicBlock();
|
|
|
|
unsigned Opc = Alpha::WTF;
|
|
|
|
|
2005-02-08 08:40:03 +08:00
|
|
|
Select(N.getOperand(0)); //chain
|
|
|
|
SDOperand CC = N.getOperand(1);
|
2005-02-10 14:25:22 +08:00
|
|
|
|
2005-02-08 08:40:03 +08:00
|
|
|
if (CC.getOpcode() == ISD::SETCC)
|
2005-02-10 14:25:22 +08:00
|
|
|
{
|
|
|
|
SetCCSDNode* SetCC = dyn_cast<SetCCSDNode>(CC.Val);
|
|
|
|
if (MVT::isInteger(SetCC->getOperand(0).getValueType())) {
|
|
|
|
//Dropping the CC is only useful if we are comparing to 0
|
|
|
|
bool isZero0 = false;
|
|
|
|
bool isZero1 = false;
|
|
|
|
bool isNE = false;
|
|
|
|
|
|
|
|
if(SetCC->getOperand(0).getOpcode() == ISD::Constant &&
|
|
|
|
cast<ConstantSDNode>(SetCC->getOperand(0))->getValue() == 0)
|
|
|
|
isZero0 = true;
|
|
|
|
if(SetCC->getOperand(1).getOpcode() == ISD::Constant &&
|
|
|
|
cast<ConstantSDNode>(SetCC->getOperand(1))->getValue() == 0)
|
|
|
|
isZero1 = true;
|
|
|
|
if(SetCC->getCondition() == ISD::SETNE)
|
|
|
|
isNE = true;
|
|
|
|
|
|
|
|
if (isZero0) {
|
2005-02-08 08:40:03 +08:00
|
|
|
switch (SetCC->getCondition()) {
|
2005-02-10 14:25:22 +08:00
|
|
|
default: CC.Val->dump(); assert(0 && "Unknown integer comparison!");
|
|
|
|
case ISD::SETEQ: Opc = Alpha::BEQ; break;
|
|
|
|
case ISD::SETLT: Opc = Alpha::BGT; break;
|
|
|
|
case ISD::SETLE: Opc = Alpha::BGE; break;
|
|
|
|
case ISD::SETGT: Opc = Alpha::BLT; break;
|
|
|
|
case ISD::SETGE: Opc = Alpha::BLE; break;
|
|
|
|
case ISD::SETULT: Opc = Alpha::BNE; break;
|
|
|
|
case ISD::SETUGT: assert(0 && "0 > (unsigned) x is never true"); break;
|
|
|
|
case ISD::SETULE: assert(0 && "0 <= (unsigned) x is always true"); break;
|
|
|
|
case ISD::SETUGE: Opc = Alpha::BEQ; break; //Technically you could have this CC
|
|
|
|
case ISD::SETNE: Opc = Alpha::BNE; break;
|
2005-02-08 08:40:03 +08:00
|
|
|
}
|
2005-02-10 14:25:22 +08:00
|
|
|
unsigned Tmp1 = SelectExpr(SetCC->getOperand(1));
|
|
|
|
BuildMI(BB, Opc, 2).addReg(Tmp1).addMBB(Dest);
|
|
|
|
return;
|
|
|
|
} else if (isZero1) {
|
|
|
|
switch (SetCC->getCondition()) {
|
|
|
|
default: CC.Val->dump(); assert(0 && "Unknown integer comparison!");
|
|
|
|
case ISD::SETEQ: Opc = Alpha::BEQ; break;
|
|
|
|
case ISD::SETLT: Opc = Alpha::BLT; break;
|
|
|
|
case ISD::SETLE: Opc = Alpha::BLE; break;
|
|
|
|
case ISD::SETGT: Opc = Alpha::BGT; break;
|
|
|
|
case ISD::SETGE: Opc = Alpha::BGE; break;
|
|
|
|
case ISD::SETULT: assert(0 && "x (unsigned) < 0 is never true"); break;
|
|
|
|
case ISD::SETUGT: Opc = Alpha::BNE; break;
|
|
|
|
case ISD::SETULE: Opc = Alpha::BEQ; break; //Technically you could have this CC
|
|
|
|
case ISD::SETUGE: assert(0 && "x (unsgined >= 0 is always true"); break;
|
|
|
|
case ISD::SETNE: Opc = Alpha::BNE; break;
|
|
|
|
}
|
|
|
|
unsigned Tmp1 = SelectExpr(SetCC->getOperand(0));
|
|
|
|
BuildMI(BB, Opc, 2).addReg(Tmp1).addMBB(Dest);
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
unsigned Tmp1 = SelectExpr(CC);
|
|
|
|
if (isNE)
|
|
|
|
BuildMI(BB, Alpha::BEQ, 2).addReg(CCInvMap[CC]).addMBB(Dest);
|
|
|
|
else
|
|
|
|
BuildMI(BB, Alpha::BNE, 2).addReg(Tmp1).addMBB(Dest);
|
2005-02-08 08:40:03 +08:00
|
|
|
return;
|
|
|
|
}
|
2005-02-10 14:25:22 +08:00
|
|
|
} else { //FP
|
|
|
|
//Any comparison between 2 values should be codegened as an folded branch, as moving
|
|
|
|
//CC to the integer register is very expensive
|
|
|
|
//for a cmp b: c = a - b;
|
|
|
|
//a = b: c = 0
|
|
|
|
//a < b: c < 0
|
|
|
|
//a > b: c > 0
|
2005-02-26 06:55:15 +08:00
|
|
|
|
|
|
|
bool invTest = false;
|
|
|
|
unsigned Tmp3;
|
|
|
|
|
|
|
|
ConstantFPSDNode *CN;
|
|
|
|
if ((CN = dyn_cast<ConstantFPSDNode>(SetCC->getOperand(1)))
|
|
|
|
&& (CN->isExactlyValue(+0.0) || CN->isExactlyValue(-0.0)))
|
|
|
|
Tmp3 = SelectExpr(SetCC->getOperand(0));
|
|
|
|
else if ((CN = dyn_cast<ConstantFPSDNode>(SetCC->getOperand(0)))
|
|
|
|
&& (CN->isExactlyValue(+0.0) || CN->isExactlyValue(-0.0)))
|
|
|
|
{
|
|
|
|
Tmp3 = SelectExpr(SetCC->getOperand(1));
|
|
|
|
invTest = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unsigned Tmp1 = SelectExpr(SetCC->getOperand(0));
|
|
|
|
unsigned Tmp2 = SelectExpr(SetCC->getOperand(1));
|
|
|
|
bool isD = SetCC->getOperand(0).getValueType() == MVT::f64;
|
|
|
|
Tmp3 = MakeReg(isD ? MVT::f64 : MVT::f32);
|
|
|
|
BuildMI(BB, isD ? Alpha::SUBT : Alpha::SUBS, 2, Tmp3)
|
|
|
|
.addReg(Tmp1).addReg(Tmp2);
|
|
|
|
}
|
2005-02-10 14:25:22 +08:00
|
|
|
|
|
|
|
switch (SetCC->getCondition()) {
|
|
|
|
default: CC.Val->dump(); assert(0 && "Unknown FP comparison!");
|
2005-02-26 06:55:15 +08:00
|
|
|
case ISD::SETEQ: Opc = invTest ? Alpha::FBNE : Alpha::FBEQ; break;
|
|
|
|
case ISD::SETLT: Opc = invTest ? Alpha::FBGT : Alpha::FBLT; break;
|
|
|
|
case ISD::SETLE: Opc = invTest ? Alpha::FBGE : Alpha::FBLE; break;
|
|
|
|
case ISD::SETGT: Opc = invTest ? Alpha::FBLT : Alpha::FBGT; break;
|
|
|
|
case ISD::SETGE: Opc = invTest ? Alpha::FBLE : Alpha::FBGE; break;
|
|
|
|
case ISD::SETNE: Opc = invTest ? Alpha::FBEQ : Alpha::FBNE; break;
|
2005-02-10 14:25:22 +08:00
|
|
|
}
|
|
|
|
BuildMI(BB, Opc, 2).addReg(Tmp3).addMBB(Dest);
|
2005-02-08 08:40:03 +08:00
|
|
|
return;
|
|
|
|
}
|
2005-02-10 14:25:22 +08:00
|
|
|
abort(); //Should never be reached
|
|
|
|
} else {
|
|
|
|
//Giveup and do the stupid thing
|
|
|
|
unsigned Tmp1 = SelectExpr(CC);
|
|
|
|
BuildMI(BB, Alpha::BNE, 2).addReg(Tmp1).addMBB(Dest);
|
|
|
|
return;
|
|
|
|
}
|
2005-02-08 08:40:03 +08:00
|
|
|
abort(); //Should never be reached
|
|
|
|
}
|
|
|
|
|
2005-01-28 14:57:18 +08:00
|
|
|
unsigned ISel::SelectExprFP(SDOperand N, unsigned Result)
|
|
|
|
{
|
|
|
|
unsigned Tmp1, Tmp2, Tmp3;
|
|
|
|
unsigned Opc = 0;
|
|
|
|
SDNode *Node = N.Val;
|
|
|
|
MVT::ValueType DestType = N.getValueType();
|
|
|
|
unsigned opcode = N.getOpcode();
|
|
|
|
|
|
|
|
switch (opcode) {
|
|
|
|
default:
|
|
|
|
Node->dump();
|
|
|
|
assert(0 && "Node not handled!\n");
|
2005-01-29 23:42:07 +08:00
|
|
|
|
2005-02-05 21:19:12 +08:00
|
|
|
case ISD::SELECT:
|
|
|
|
{
|
2005-03-04 05:47:53 +08:00
|
|
|
//Tmp1 = SelectExpr(N.getOperand(0)); //Cond
|
|
|
|
unsigned TV = SelectExpr(N.getOperand(1)); //Use if TRUE
|
|
|
|
unsigned FV = SelectExpr(N.getOperand(2)); //Use if FALSE
|
|
|
|
|
|
|
|
SDOperand CC = N.getOperand(0);
|
|
|
|
SetCCSDNode* SetCC = dyn_cast<SetCCSDNode>(CC.Val);
|
|
|
|
|
|
|
|
if (CC.getOpcode() == ISD::SETCC &&
|
|
|
|
!MVT::isInteger(SetCC->getOperand(0).getValueType()))
|
|
|
|
{ //FP Setcc -> Select yay!
|
|
|
|
|
|
|
|
|
|
|
|
//for a cmp b: c = a - b;
|
|
|
|
//a = b: c = 0
|
|
|
|
//a < b: c < 0
|
|
|
|
//a > b: c > 0
|
|
|
|
|
|
|
|
bool invTest = false;
|
|
|
|
unsigned Tmp3;
|
|
|
|
|
|
|
|
ConstantFPSDNode *CN;
|
|
|
|
if ((CN = dyn_cast<ConstantFPSDNode>(SetCC->getOperand(1)))
|
|
|
|
&& (CN->isExactlyValue(+0.0) || CN->isExactlyValue(-0.0)))
|
|
|
|
Tmp3 = SelectExpr(SetCC->getOperand(0));
|
|
|
|
else if ((CN = dyn_cast<ConstantFPSDNode>(SetCC->getOperand(0)))
|
|
|
|
&& (CN->isExactlyValue(+0.0) || CN->isExactlyValue(-0.0)))
|
|
|
|
{
|
|
|
|
Tmp3 = SelectExpr(SetCC->getOperand(1));
|
|
|
|
invTest = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unsigned Tmp1 = SelectExpr(SetCC->getOperand(0));
|
|
|
|
unsigned Tmp2 = SelectExpr(SetCC->getOperand(1));
|
|
|
|
bool isD = SetCC->getOperand(0).getValueType() == MVT::f64;
|
|
|
|
Tmp3 = MakeReg(isD ? MVT::f64 : MVT::f32);
|
|
|
|
BuildMI(BB, isD ? Alpha::SUBT : Alpha::SUBS, 2, Tmp3)
|
|
|
|
.addReg(Tmp1).addReg(Tmp2);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (SetCC->getCondition()) {
|
|
|
|
default: CC.Val->dump(); assert(0 && "Unknown FP comparison!");
|
|
|
|
case ISD::SETEQ: Opc = invTest ? Alpha::FCMOVNE : Alpha::FCMOVEQ; break;
|
|
|
|
case ISD::SETLT: Opc = invTest ? Alpha::FCMOVGT : Alpha::FCMOVLT; break;
|
|
|
|
case ISD::SETLE: Opc = invTest ? Alpha::FCMOVGE : Alpha::FCMOVLE; break;
|
|
|
|
case ISD::SETGT: Opc = invTest ? Alpha::FCMOVLT : Alpha::FCMOVGT; break;
|
|
|
|
case ISD::SETGE: Opc = invTest ? Alpha::FCMOVLE : Alpha::FCMOVGE; break;
|
|
|
|
case ISD::SETNE: Opc = invTest ? Alpha::FCMOVEQ : Alpha::FCMOVNE; break;
|
|
|
|
}
|
2005-03-05 04:09:23 +08:00
|
|
|
BuildMI(BB, Opc, 3, Result).addReg(FV).addReg(TV).addReg(Tmp3);
|
2005-03-04 05:47:53 +08:00
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Tmp1 = SelectExpr(N.getOperand(0)); //Cond
|
|
|
|
// Spill the cond to memory and reload it from there.
|
|
|
|
unsigned Size = MVT::getSizeInBits(MVT::f64)/8;
|
|
|
|
MachineFunction *F = BB->getParent();
|
|
|
|
int FrameIdx = F->getFrameInfo()->CreateStackObject(Size, 8);
|
|
|
|
unsigned Tmp4 = MakeReg(MVT::f64);
|
|
|
|
BuildMI(BB, Alpha::STQ, 3).addReg(Tmp1).addFrameIndex(FrameIdx).addReg(Alpha::F31);
|
|
|
|
BuildMI(BB, Alpha::LDT, 2, Tmp4).addFrameIndex(FrameIdx).addReg(Alpha::F31);
|
|
|
|
//now ideally, we don't have to do anything to the flag...
|
|
|
|
// Get the condition into the zero flag.
|
|
|
|
BuildMI(BB, Alpha::FCMOVEQ, 3, Result).addReg(TV).addReg(FV).addReg(Tmp4);
|
|
|
|
return Result;
|
|
|
|
}
|
2005-02-05 21:19:12 +08:00
|
|
|
}
|
|
|
|
|
2005-02-01 09:37:24 +08:00
|
|
|
case ISD::FP_ROUND:
|
2005-02-10 14:25:22 +08:00
|
|
|
assert (DestType == MVT::f32 &&
|
|
|
|
N.getOperand(0).getValueType() == MVT::f64 &&
|
|
|
|
"only f64 to f32 conversion supported here");
|
2005-02-01 09:37:24 +08:00
|
|
|
Tmp1 = SelectExpr(N.getOperand(0));
|
|
|
|
BuildMI(BB, Alpha::CVTTS, 1, Result).addReg(Tmp1);
|
|
|
|
return Result;
|
|
|
|
|
2005-01-31 04:42:36 +08:00
|
|
|
case ISD::FP_EXTEND:
|
2005-02-10 14:25:22 +08:00
|
|
|
assert (DestType == MVT::f64 &&
|
|
|
|
N.getOperand(0).getValueType() == MVT::f32 &&
|
|
|
|
"only f32 to f64 conversion supported here");
|
2005-01-31 04:42:36 +08:00
|
|
|
Tmp1 = SelectExpr(N.getOperand(0));
|
|
|
|
BuildMI(BB, Alpha::CVTST, 1, Result).addReg(Tmp1);
|
|
|
|
return Result;
|
|
|
|
|
2005-01-29 23:42:07 +08:00
|
|
|
case ISD::CopyFromReg:
|
|
|
|
{
|
|
|
|
// Make sure we generate both values.
|
|
|
|
if (Result != notIn)
|
|
|
|
ExprMap[N.getValue(1)] = notIn; // Generate the token
|
|
|
|
else
|
|
|
|
Result = ExprMap[N.getValue(0)] = MakeReg(N.getValue(0).getValueType());
|
|
|
|
|
|
|
|
SDOperand Chain = N.getOperand(0);
|
|
|
|
|
|
|
|
Select(Chain);
|
|
|
|
unsigned r = dyn_cast<RegSDNode>(Node)->getReg();
|
|
|
|
//std::cerr << "CopyFromReg " << Result << " = " << r << "\n";
|
|
|
|
BuildMI(BB, Alpha::CPYS, 2, Result).addReg(r).addReg(r);
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
2005-01-29 07:17:54 +08:00
|
|
|
case ISD::LOAD:
|
|
|
|
{
|
|
|
|
// Make sure we generate both values.
|
|
|
|
if (Result != notIn)
|
|
|
|
ExprMap[N.getValue(1)] = notIn; // Generate the token
|
|
|
|
else
|
|
|
|
Result = ExprMap[N.getValue(0)] = MakeReg(N.getValue(0).getValueType());
|
2005-02-04 05:01:15 +08:00
|
|
|
|
2005-02-07 14:31:44 +08:00
|
|
|
DestType = N.getValue(0).getValueType();
|
2005-02-04 05:01:15 +08:00
|
|
|
|
2005-01-29 07:17:54 +08:00
|
|
|
SDOperand Chain = N.getOperand(0);
|
|
|
|
SDOperand Address = N.getOperand(1);
|
2005-02-06 23:40:40 +08:00
|
|
|
Select(Chain);
|
2005-02-07 00:22:15 +08:00
|
|
|
Opc = DestType == MVT::f64 ? Alpha::LDT : Alpha::LDS;
|
|
|
|
|
2005-02-10 14:25:22 +08:00
|
|
|
if (Address.getOpcode() == ISD::GlobalAddress) {
|
|
|
|
AlphaLowering.restoreGP(BB);
|
|
|
|
Opc = GetSymVersion(Opc);
|
|
|
|
BuildMI(BB, Opc, 1, Result).addGlobalAddress(cast<GlobalAddressSDNode>(Address)->getGlobal());
|
|
|
|
}
|
2005-02-02 04:40:27 +08:00
|
|
|
else if (ConstantPoolSDNode *CP = dyn_cast<ConstantPoolSDNode>(Address)) {
|
2005-02-06 00:41:03 +08:00
|
|
|
AlphaLowering.restoreGP(BB);
|
2005-02-07 00:22:15 +08:00
|
|
|
Opc = GetSymVersion(Opc);
|
2005-02-06 01:41:39 +08:00
|
|
|
BuildMI(BB, Opc, 1, Result).addConstantPoolIndex(CP->getIndex());
|
2005-02-02 04:40:27 +08:00
|
|
|
}
|
2005-02-10 14:25:22 +08:00
|
|
|
else if(Address.getOpcode() == ISD::FrameIndex) {
|
2005-02-23 05:59:48 +08:00
|
|
|
BuildMI(BB, Opc, 2, Result)
|
|
|
|
.addFrameIndex(cast<FrameIndexSDNode>(Address)->getIndex())
|
|
|
|
.addReg(Alpha::F31);
|
2005-02-10 14:25:22 +08:00
|
|
|
} else {
|
|
|
|
long offset;
|
|
|
|
SelectAddr(Address, Tmp1, offset);
|
|
|
|
BuildMI(BB, Opc, 2, Result).addImm(offset).addReg(Tmp1);
|
|
|
|
}
|
2005-01-29 07:17:54 +08:00
|
|
|
return Result;
|
|
|
|
}
|
2005-01-28 14:57:18 +08:00
|
|
|
case ISD::ConstantFP:
|
|
|
|
if (ConstantFPSDNode *CN = dyn_cast<ConstantFPSDNode>(N)) {
|
|
|
|
if (CN->isExactlyValue(+0.0)) {
|
|
|
|
BuildMI(BB, Alpha::CPYS, 2, Result).addReg(Alpha::F31).addReg(Alpha::F31);
|
2005-02-04 05:01:15 +08:00
|
|
|
} else if ( CN->isExactlyValue(-0.0)) {
|
|
|
|
BuildMI(BB, Alpha::CPYSN, 2, Result).addReg(Alpha::F31).addReg(Alpha::F31);
|
2005-01-28 14:57:18 +08:00
|
|
|
} else {
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Result;
|
|
|
|
|
2005-03-22 08:24:07 +08:00
|
|
|
case ISD::SDIV:
|
2005-01-28 14:57:18 +08:00
|
|
|
case ISD::MUL:
|
|
|
|
case ISD::ADD:
|
|
|
|
case ISD::SUB:
|
|
|
|
switch( opcode ) {
|
|
|
|
case ISD::MUL: Opc = DestType == MVT::f64 ? Alpha::MULT : Alpha::MULS; break;
|
|
|
|
case ISD::ADD: Opc = DestType == MVT::f64 ? Alpha::ADDT : Alpha::ADDS; break;
|
|
|
|
case ISD::SUB: Opc = DestType == MVT::f64 ? Alpha::SUBT : Alpha::SUBS; break;
|
|
|
|
case ISD::SDIV: Opc = DestType == MVT::f64 ? Alpha::DIVT : Alpha::DIVS; break;
|
|
|
|
};
|
2005-02-26 06:55:15 +08:00
|
|
|
|
|
|
|
ConstantFPSDNode *CN;
|
|
|
|
if (opcode == ISD::SUB
|
|
|
|
&& (CN = dyn_cast<ConstantFPSDNode>(N.getOperand(0)))
|
|
|
|
&& (CN->isExactlyValue(+0.0) || CN->isExactlyValue(-0.0)))
|
|
|
|
{
|
|
|
|
Tmp2 = SelectExpr(N.getOperand(1));
|
|
|
|
BuildMI(BB, Alpha::CPYSN, 2, Result).addReg(Tmp2).addReg(Tmp2);
|
|
|
|
} else {
|
|
|
|
Tmp1 = SelectExpr(N.getOperand(0));
|
|
|
|
Tmp2 = SelectExpr(N.getOperand(1));
|
|
|
|
BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2);
|
|
|
|
}
|
2005-01-28 14:57:18 +08:00
|
|
|
return Result;
|
|
|
|
|
2005-01-29 23:42:07 +08:00
|
|
|
case ISD::EXTLOAD:
|
2005-02-06 23:40:40 +08:00
|
|
|
{
|
|
|
|
//include a conversion sequence for float loads to double
|
|
|
|
if (Result != notIn)
|
|
|
|
ExprMap[N.getValue(1)] = notIn; // Generate the token
|
|
|
|
else
|
|
|
|
Result = ExprMap[N.getValue(0)] = MakeReg(N.getValue(0).getValueType());
|
|
|
|
|
2005-02-07 13:33:15 +08:00
|
|
|
Tmp1 = MakeReg(MVT::f32);
|
2005-02-06 23:40:40 +08:00
|
|
|
|
2005-02-10 14:25:22 +08:00
|
|
|
assert(cast<MVTSDNode>(Node)->getExtraValueType() == MVT::f32 &&
|
|
|
|
"EXTLOAD not from f32");
|
2005-02-06 23:40:40 +08:00
|
|
|
assert(Node->getValueType(0) == MVT::f64 && "EXTLOAD not to f64");
|
|
|
|
|
|
|
|
SDOperand Chain = N.getOperand(0);
|
|
|
|
SDOperand Address = N.getOperand(1);
|
|
|
|
Select(Chain);
|
|
|
|
|
2005-02-10 14:25:22 +08:00
|
|
|
if (Address.getOpcode() == ISD::GlobalAddress) {
|
|
|
|
AlphaLowering.restoreGP(BB);
|
|
|
|
BuildMI(BB, Alpha::LDS_SYM, 1, Tmp1).addGlobalAddress(cast<GlobalAddressSDNode>(Address)->getGlobal());
|
|
|
|
}
|
|
|
|
else if (ConstantPoolSDNode *CP =
|
|
|
|
dyn_cast<ConstantPoolSDNode>(N.getOperand(1)))
|
|
|
|
{
|
|
|
|
AlphaLowering.restoreGP(BB);
|
|
|
|
BuildMI(BB, Alpha::LDS_SYM, 1, Tmp1).addConstantPoolIndex(CP->getIndex());
|
|
|
|
}
|
|
|
|
else if(Address.getOpcode() == ISD::FrameIndex) {
|
|
|
|
Tmp2 = cast<FrameIndexSDNode>(Address)->getIndex();
|
2005-02-23 05:59:48 +08:00
|
|
|
BuildMI(BB, Alpha::LDS, 2, Tmp1)
|
|
|
|
.addFrameIndex(cast<FrameIndexSDNode>(Address)->getIndex())
|
|
|
|
.addReg(Alpha::F31);
|
2005-02-10 14:25:22 +08:00
|
|
|
} else {
|
|
|
|
long offset;
|
|
|
|
SelectAddr(Address, Tmp2, offset);
|
|
|
|
BuildMI(BB, Alpha::LDS, 1, Tmp1).addImm(offset).addReg(Tmp2);
|
|
|
|
}
|
2005-02-07 14:31:44 +08:00
|
|
|
BuildMI(BB, Alpha::CVTST, 1, Result).addReg(Tmp1);
|
2005-02-04 05:01:15 +08:00
|
|
|
return Result;
|
|
|
|
}
|
2005-01-29 23:42:07 +08:00
|
|
|
|
2005-02-02 04:40:27 +08:00
|
|
|
case ISD::UINT_TO_FP:
|
|
|
|
case ISD::SINT_TO_FP:
|
2005-01-28 14:57:18 +08:00
|
|
|
{
|
2005-02-10 14:25:22 +08:00
|
|
|
assert (N.getOperand(0).getValueType() == MVT::i64
|
|
|
|
&& "only quads can be loaded from");
|
2005-01-28 14:57:18 +08:00
|
|
|
Tmp1 = SelectExpr(N.getOperand(0)); // Get the operand register
|
2005-01-31 09:44:26 +08:00
|
|
|
Tmp2 = MakeReg(MVT::f64);
|
2005-01-29 23:42:07 +08:00
|
|
|
|
|
|
|
//The hard way:
|
|
|
|
// Spill the integer to memory and reload it from there.
|
|
|
|
unsigned Size = MVT::getSizeInBits(MVT::i64)/8;
|
|
|
|
MachineFunction *F = BB->getParent();
|
|
|
|
int FrameIdx = F->getFrameInfo()->CreateStackObject(Size, Size);
|
|
|
|
|
2005-01-31 09:44:26 +08:00
|
|
|
BuildMI(BB, Alpha::STQ, 3).addReg(Tmp1).addFrameIndex(FrameIdx).addReg(Alpha::F31);
|
|
|
|
BuildMI(BB, Alpha::LDT, 2, Tmp2).addFrameIndex(FrameIdx).addReg(Alpha::F31);
|
|
|
|
Opc = DestType == MVT::f64 ? Alpha::CVTQT : Alpha::CVTQS;
|
|
|
|
BuildMI(BB, Opc, 1, Result).addReg(Tmp2);
|
2005-01-29 23:42:07 +08:00
|
|
|
|
|
|
|
//The easy way: doesn't work
|
2005-02-10 14:25:22 +08:00
|
|
|
// //so these instructions are not supported on ev56
|
|
|
|
// Opc = DestType == MVT::f64 ? Alpha::ITOFT : Alpha::ITOFS;
|
|
|
|
// BuildMI(BB, Opc, 1, Tmp2).addReg(Tmp1);
|
|
|
|
// Opc = DestType == MVT::f64 ? Alpha::CVTQT : Alpha::CVTQS;
|
|
|
|
// BuildMI(BB, Opc, 1, Result).addReg(Tmp1);
|
2005-01-29 23:42:07 +08:00
|
|
|
|
2005-01-28 14:57:18 +08:00
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
assert(0 && "should not get here");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-01-23 07:41:55 +08:00
|
|
|
unsigned ISel::SelectExpr(SDOperand N) {
|
|
|
|
unsigned Result;
|
|
|
|
unsigned Tmp1, Tmp2, Tmp3;
|
|
|
|
unsigned Opc = 0;
|
2005-01-28 14:57:18 +08:00
|
|
|
unsigned opcode = N.getOpcode();
|
2005-01-23 07:41:55 +08:00
|
|
|
|
|
|
|
SDNode *Node = N.Val;
|
2005-01-28 14:57:18 +08:00
|
|
|
MVT::ValueType DestType = N.getValueType();
|
2005-01-23 07:41:55 +08:00
|
|
|
|
|
|
|
unsigned &Reg = ExprMap[N];
|
|
|
|
if (Reg) return Reg;
|
|
|
|
|
|
|
|
if (N.getOpcode() != ISD::CALL)
|
|
|
|
Reg = Result = (N.getValueType() != MVT::Other) ?
|
2005-01-29 07:17:54 +08:00
|
|
|
MakeReg(N.getValueType()) : notIn;
|
2005-01-23 07:41:55 +08:00
|
|
|
else {
|
|
|
|
// If this is a call instruction, make sure to prepare ALL of the result
|
|
|
|
// values as well as the chain.
|
|
|
|
if (Node->getNumValues() == 1)
|
2005-01-29 07:17:54 +08:00
|
|
|
Reg = Result = notIn; // Void call, just a chain.
|
2005-01-23 07:41:55 +08:00
|
|
|
else {
|
|
|
|
Result = MakeReg(Node->getValueType(0));
|
|
|
|
ExprMap[N.getValue(0)] = Result;
|
|
|
|
for (unsigned i = 1, e = N.Val->getNumValues()-1; i != e; ++i)
|
|
|
|
ExprMap[N.getValue(i)] = MakeReg(Node->getValueType(i));
|
2005-01-29 07:17:54 +08:00
|
|
|
ExprMap[SDOperand(Node, Node->getNumValues()-1)] = notIn;
|
2005-01-23 07:41:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-02 23:05:33 +08:00
|
|
|
if (DestType == MVT::f64 || DestType == MVT::f32 ||
|
2005-02-07 14:21:37 +08:00
|
|
|
(
|
2005-02-10 14:25:22 +08:00
|
|
|
(opcode == ISD::LOAD || opcode == ISD::CopyFromReg ||
|
|
|
|
opcode == ISD::EXTLOAD) &&
|
|
|
|
(N.getValue(0).getValueType() == MVT::f32 ||
|
|
|
|
N.getValue(0).getValueType() == MVT::f64)
|
2005-02-07 14:21:37 +08:00
|
|
|
)
|
|
|
|
)
|
2005-01-28 14:57:18 +08:00
|
|
|
return SelectExprFP(N, Result);
|
|
|
|
|
|
|
|
switch (opcode) {
|
2005-01-23 07:41:55 +08:00
|
|
|
default:
|
|
|
|
Node->dump();
|
|
|
|
assert(0 && "Node not handled!\n");
|
|
|
|
|
2005-02-23 05:59:48 +08:00
|
|
|
case ISD::DYNAMIC_STACKALLOC:
|
|
|
|
// Generate both result values.
|
2005-02-24 01:33:42 +08:00
|
|
|
if (Result != notIn)
|
|
|
|
ExprMap[N.getValue(1)] = notIn; // Generate the token
|
2005-02-23 05:59:48 +08:00
|
|
|
else
|
|
|
|
Result = ExprMap[N.getValue(0)] = MakeReg(N.getValue(0).getValueType());
|
|
|
|
|
|
|
|
// FIXME: We are currently ignoring the requested alignment for handling
|
|
|
|
// greater than the stack alignment. This will need to be revisited at some
|
|
|
|
// point. Align = N.getOperand(2);
|
|
|
|
|
|
|
|
if (!isa<ConstantSDNode>(N.getOperand(2)) ||
|
|
|
|
cast<ConstantSDNode>(N.getOperand(2))->getValue() != 0) {
|
|
|
|
std::cerr << "Cannot allocate stack object with greater alignment than"
|
|
|
|
<< " the stack alignment yet!";
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
Select(N.getOperand(0));
|
|
|
|
if (ConstantSDNode* CN = dyn_cast<ConstantSDNode>(N.getOperand(1)))
|
|
|
|
{
|
|
|
|
if (CN->getValue() < 32000)
|
|
|
|
{
|
|
|
|
BuildMI(BB, Alpha::LDA, 2, Alpha::R30)
|
|
|
|
.addImm(-CN->getValue()).addReg(Alpha::R30);
|
|
|
|
} else {
|
|
|
|
Tmp1 = SelectExpr(N.getOperand(1));
|
|
|
|
// Subtract size from stack pointer, thereby allocating some space.
|
|
|
|
BuildMI(BB, Alpha::SUBQ, 2, Alpha::R30).addReg(Alpha::R30).addReg(Tmp1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Tmp1 = SelectExpr(N.getOperand(1));
|
|
|
|
// Subtract size from stack pointer, thereby allocating some space.
|
|
|
|
BuildMI(BB, Alpha::SUBQ, 2, Alpha::R30).addReg(Alpha::R30).addReg(Tmp1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Put a pointer to the space into the result register, by copying the stack
|
|
|
|
// pointer.
|
2005-02-23 07:29:25 +08:00
|
|
|
BuildMI(BB, Alpha::BIS, 2, Result).addReg(Alpha::R30).addReg(Alpha::R30);
|
2005-02-23 05:59:48 +08:00
|
|
|
return Result;
|
|
|
|
|
2005-03-05 04:09:23 +08:00
|
|
|
// case ISD::ConstantPool:
|
|
|
|
// Tmp1 = cast<ConstantPoolSDNode>(N)->getIndex();
|
|
|
|
// AlphaLowering.restoreGP(BB);
|
|
|
|
// BuildMI(BB, Alpha::LDQ_SYM, 1, Result).addConstantPoolIndex(Tmp1);
|
|
|
|
// return Result;
|
2005-01-29 23:42:07 +08:00
|
|
|
|
2005-01-23 07:41:55 +08:00
|
|
|
case ISD::FrameIndex:
|
2005-02-23 05:59:48 +08:00
|
|
|
BuildMI(BB, Alpha::LDA, 2, Result)
|
|
|
|
.addFrameIndex(cast<FrameIndexSDNode>(N)->getIndex())
|
|
|
|
.addReg(Alpha::F31);
|
2005-01-23 07:41:55 +08:00
|
|
|
return Result;
|
|
|
|
|
|
|
|
case ISD::EXTLOAD:
|
2005-02-07 13:18:02 +08:00
|
|
|
case ISD::ZEXTLOAD:
|
2005-01-23 07:41:55 +08:00
|
|
|
case ISD::SEXTLOAD:
|
2005-02-07 13:33:15 +08:00
|
|
|
case ISD::LOAD:
|
2005-02-06 23:40:40 +08:00
|
|
|
{
|
|
|
|
// Make sure we generate both values.
|
|
|
|
if (Result != notIn)
|
|
|
|
ExprMap[N.getValue(1)] = notIn; // Generate the token
|
|
|
|
else
|
|
|
|
Result = ExprMap[N.getValue(0)] = MakeReg(N.getValue(0).getValueType());
|
2005-01-23 07:41:55 +08:00
|
|
|
|
2005-02-06 23:40:40 +08:00
|
|
|
SDOperand Chain = N.getOperand(0);
|
|
|
|
SDOperand Address = N.getOperand(1);
|
|
|
|
Select(Chain);
|
|
|
|
|
2005-02-10 14:25:22 +08:00
|
|
|
assert(Node->getValueType(0) == MVT::i64 &&
|
|
|
|
"Unknown type to sign extend to.");
|
2005-02-07 13:55:55 +08:00
|
|
|
if (opcode == ISD::LOAD)
|
|
|
|
Opc = Alpha::LDQ;
|
|
|
|
else
|
2005-02-06 23:40:40 +08:00
|
|
|
switch (cast<MVTSDNode>(Node)->getExtraValueType()) {
|
|
|
|
default: Node->dump(); assert(0 && "Bad sign extend!");
|
2005-02-10 14:25:22 +08:00
|
|
|
case MVT::i32: Opc = Alpha::LDL;
|
|
|
|
assert(opcode != ISD::ZEXTLOAD && "Not sext"); break;
|
|
|
|
case MVT::i16: Opc = Alpha::LDWU;
|
|
|
|
assert(opcode != ISD::SEXTLOAD && "Not zext"); break;
|
2005-02-07 13:18:02 +08:00
|
|
|
case MVT::i1: //FIXME: Treat i1 as i8 since there are problems otherwise
|
2005-02-10 14:25:22 +08:00
|
|
|
case MVT::i8: Opc = Alpha::LDBU;
|
|
|
|
assert(opcode != ISD::SEXTLOAD && "Not zext"); break;
|
2005-02-06 23:40:40 +08:00
|
|
|
}
|
|
|
|
|
2005-02-10 14:25:22 +08:00
|
|
|
if (Address.getOpcode() == ISD::GlobalAddress) {
|
|
|
|
AlphaLowering.restoreGP(BB);
|
|
|
|
Opc = GetSymVersion(Opc);
|
|
|
|
BuildMI(BB, Opc, 1, Result).addGlobalAddress(cast<GlobalAddressSDNode>(Address)->getGlobal());
|
|
|
|
}
|
2005-02-06 23:40:40 +08:00
|
|
|
else if (ConstantPoolSDNode *CP = dyn_cast<ConstantPoolSDNode>(Address)) {
|
|
|
|
AlphaLowering.restoreGP(BB);
|
2005-02-07 00:22:15 +08:00
|
|
|
Opc = GetSymVersion(Opc);
|
2005-02-10 14:25:22 +08:00
|
|
|
BuildMI(BB, Opc, 1, Result).addConstantPoolIndex(CP->getIndex());
|
|
|
|
}
|
|
|
|
else if(Address.getOpcode() == ISD::FrameIndex) {
|
2005-02-23 05:59:48 +08:00
|
|
|
BuildMI(BB, Opc, 2, Result)
|
|
|
|
.addFrameIndex(cast<FrameIndexSDNode>(Address)->getIndex())
|
|
|
|
.addReg(Alpha::F31);
|
2005-02-10 14:25:22 +08:00
|
|
|
} else {
|
|
|
|
long offset;
|
|
|
|
SelectAddr(Address, Tmp1, offset);
|
|
|
|
BuildMI(BB, Opc, 2, Result).addImm(offset).addReg(Tmp1);
|
2005-02-06 23:40:40 +08:00
|
|
|
}
|
|
|
|
return Result;
|
2005-01-25 08:35:34 +08:00
|
|
|
}
|
|
|
|
|
2005-01-23 07:41:55 +08:00
|
|
|
case ISD::GlobalAddress:
|
|
|
|
AlphaLowering.restoreGP(BB);
|
|
|
|
BuildMI(BB, Alpha::LOAD_ADDR, 1, Result)
|
|
|
|
.addGlobalAddress(cast<GlobalAddressSDNode>(N)->getGlobal());
|
|
|
|
return Result;
|
|
|
|
|
|
|
|
case ISD::CALL:
|
|
|
|
{
|
|
|
|
Select(N.getOperand(0));
|
2005-01-27 05:54:09 +08:00
|
|
|
|
2005-01-23 07:41:55 +08:00
|
|
|
// The chain for this call is now lowered.
|
2005-01-29 07:17:54 +08:00
|
|
|
ExprMap.insert(std::make_pair(N.getValue(Node->getNumValues()-1), notIn));
|
2005-01-23 07:41:55 +08:00
|
|
|
|
|
|
|
//grab the arguments
|
|
|
|
std::vector<unsigned> argvregs;
|
2005-01-31 04:42:36 +08:00
|
|
|
//assert(Node->getNumOperands() < 8 && "Only 6 args supported");
|
2005-01-23 07:41:55 +08:00
|
|
|
for(int i = 2, e = Node->getNumOperands(); i < e; ++i)
|
2005-02-10 14:25:22 +08:00
|
|
|
argvregs.push_back(SelectExpr(N.getOperand(i)));
|
2005-01-27 05:54:09 +08:00
|
|
|
|
2005-01-30 08:35:27 +08:00
|
|
|
//in reg args
|
|
|
|
for(int i = 0, e = std::min(6, (int)argvregs.size()); i < e; ++i)
|
2005-02-10 14:25:22 +08:00
|
|
|
{
|
|
|
|
unsigned args_int[] = {Alpha::R16, Alpha::R17, Alpha::R18,
|
|
|
|
Alpha::R19, Alpha::R20, Alpha::R21};
|
|
|
|
unsigned args_float[] = {Alpha::F16, Alpha::F17, Alpha::F18,
|
|
|
|
Alpha::F19, Alpha::F20, Alpha::F21};
|
|
|
|
switch(N.getOperand(i+2).getValueType()) {
|
|
|
|
default:
|
|
|
|
Node->dump();
|
|
|
|
N.getOperand(i).Val->dump();
|
|
|
|
std::cerr << "Type for " << i << " is: " <<
|
|
|
|
N.getOperand(i+2).getValueType() << "\n";
|
|
|
|
assert(0 && "Unknown value type for call");
|
|
|
|
case MVT::i1:
|
|
|
|
case MVT::i8:
|
|
|
|
case MVT::i16:
|
|
|
|
case MVT::i32:
|
|
|
|
case MVT::i64:
|
|
|
|
BuildMI(BB, Alpha::BIS, 2, args_int[i]).addReg(argvregs[i]).addReg(argvregs[i]);
|
|
|
|
break;
|
|
|
|
case MVT::f32:
|
|
|
|
case MVT::f64:
|
|
|
|
BuildMI(BB, Alpha::CPYS, 2, args_float[i]).addReg(argvregs[i]).addReg(argvregs[i]);
|
|
|
|
break;
|
2005-01-30 08:35:27 +08:00
|
|
|
}
|
2005-02-10 14:25:22 +08:00
|
|
|
}
|
2005-01-30 08:35:27 +08:00
|
|
|
//in mem args
|
|
|
|
for (int i = 6, e = argvregs.size(); i < e; ++i)
|
2005-02-10 14:25:22 +08:00
|
|
|
{
|
|
|
|
switch(N.getOperand(i+2).getValueType()) {
|
|
|
|
default:
|
|
|
|
Node->dump();
|
|
|
|
N.getOperand(i).Val->dump();
|
|
|
|
std::cerr << "Type for " << i << " is: " <<
|
|
|
|
N.getOperand(i+2).getValueType() << "\n";
|
|
|
|
assert(0 && "Unknown value type for call");
|
|
|
|
case MVT::i1:
|
|
|
|
case MVT::i8:
|
|
|
|
case MVT::i16:
|
|
|
|
case MVT::i32:
|
|
|
|
case MVT::i64:
|
|
|
|
BuildMI(BB, Alpha::STQ, 3).addReg(argvregs[i]).addImm((i - 6) * 8).addReg(Alpha::R30);
|
|
|
|
break;
|
|
|
|
case MVT::f32:
|
|
|
|
BuildMI(BB, Alpha::STS, 3).addReg(argvregs[i]).addImm((i - 6) * 8).addReg(Alpha::R30);
|
|
|
|
break;
|
|
|
|
case MVT::f64:
|
|
|
|
BuildMI(BB, Alpha::STT, 3).addReg(argvregs[i]).addImm((i - 6) * 8).addReg(Alpha::R30);
|
|
|
|
break;
|
2005-01-30 08:35:27 +08:00
|
|
|
}
|
2005-02-10 14:25:22 +08:00
|
|
|
}
|
2005-01-27 05:54:09 +08:00
|
|
|
//build the right kind of call
|
|
|
|
if (GlobalAddressSDNode *GASD =
|
2005-01-31 04:42:36 +08:00
|
|
|
dyn_cast<GlobalAddressSDNode>(N.getOperand(1)))
|
2005-02-10 14:25:22 +08:00
|
|
|
{
|
2005-02-11 04:10:38 +08:00
|
|
|
//if (GASD->getGlobal()->isExternal()) {
|
2005-02-10 14:25:22 +08:00
|
|
|
//use safe calling convention
|
2005-01-31 04:42:36 +08:00
|
|
|
AlphaLowering.restoreGP(BB);
|
|
|
|
BuildMI(BB, Alpha::CALL, 1).addGlobalAddress(GASD->getGlobal(),true);
|
2005-02-11 04:10:38 +08:00
|
|
|
//} else {
|
2005-02-10 14:25:22 +08:00
|
|
|
//use PC relative branch call
|
2005-02-11 04:10:38 +08:00
|
|
|
//BuildMI(BB, Alpha::BSR, 1, Alpha::R26).addGlobalAddress(GASD->getGlobal(),true);
|
|
|
|
//}
|
2005-02-10 14:25:22 +08:00
|
|
|
}
|
2005-01-27 05:54:09 +08:00
|
|
|
else if (ExternalSymbolSDNode *ESSDN =
|
2005-01-31 04:42:36 +08:00
|
|
|
dyn_cast<ExternalSymbolSDNode>(N.getOperand(1)))
|
2005-02-10 14:25:22 +08:00
|
|
|
{
|
|
|
|
AlphaLowering.restoreGP(BB);
|
2005-03-31 02:22:52 +08:00
|
|
|
BuildMI(BB, Alpha::CALL, 1).addExternalSymbol(ESSDN->getSymbol(), true);
|
2005-02-10 14:25:22 +08:00
|
|
|
} else {
|
|
|
|
//no need to restore GP as we are doing an indirect call
|
|
|
|
Tmp1 = SelectExpr(N.getOperand(1));
|
|
|
|
BuildMI(BB, Alpha::BIS, 2, Alpha::R27).addReg(Tmp1).addReg(Tmp1);
|
|
|
|
BuildMI(BB, Alpha::JSR, 2, Alpha::R26).addReg(Alpha::R27).addImm(0);
|
|
|
|
}
|
2005-01-27 05:54:09 +08:00
|
|
|
|
|
|
|
//push the result into a virtual register
|
|
|
|
|
|
|
|
switch (Node->getValueType(0)) {
|
|
|
|
default: Node->dump(); assert(0 && "Unknown value type for call result!");
|
2005-01-29 07:17:54 +08:00
|
|
|
case MVT::Other: return notIn;
|
2005-01-27 05:54:09 +08:00
|
|
|
case MVT::i1:
|
|
|
|
case MVT::i8:
|
|
|
|
case MVT::i16:
|
|
|
|
case MVT::i32:
|
|
|
|
case MVT::i64:
|
|
|
|
BuildMI(BB, Alpha::BIS, 2, Result).addReg(Alpha::R0).addReg(Alpha::R0);
|
|
|
|
break;
|
|
|
|
case MVT::f32:
|
|
|
|
case MVT::f64:
|
|
|
|
BuildMI(BB, Alpha::CPYS, 2, Result).addReg(Alpha::F0).addReg(Alpha::F0);
|
|
|
|
break;
|
2005-01-23 07:41:55 +08:00
|
|
|
}
|
2005-01-27 05:54:09 +08:00
|
|
|
return Result+N.ResNo;
|
2005-01-23 07:41:55 +08:00
|
|
|
}
|
2005-01-27 05:54:09 +08:00
|
|
|
|
2005-01-23 07:41:55 +08:00
|
|
|
case ISD::SIGN_EXTEND:
|
2005-01-27 11:49:45 +08:00
|
|
|
abort();
|
|
|
|
|
2005-01-23 07:41:55 +08:00
|
|
|
case ISD::SIGN_EXTEND_INREG:
|
|
|
|
{
|
2005-03-22 08:24:07 +08:00
|
|
|
//do SDIV opt for all levels of ints
|
|
|
|
if (N.getOperand(0).getOpcode() == ISD::SDIV)
|
|
|
|
{
|
|
|
|
Tmp1 = SelectExpr(N.getOperand(0).getOperand(0));
|
|
|
|
Tmp2 = SelectExpr(N.getOperand(0).getOperand(1));
|
|
|
|
unsigned Size = MVT::getSizeInBits(MVT::f64)/8;
|
|
|
|
MachineFunction *F = BB->getParent();
|
|
|
|
int FrameIdxL = F->getFrameInfo()->CreateStackObject(Size, 8);
|
|
|
|
int FrameIdxR = F->getFrameInfo()->CreateStackObject(Size, 8);
|
|
|
|
int FrameIdxF = F->getFrameInfo()->CreateStackObject(Size, 8);
|
|
|
|
unsigned Tmp4 = MakeReg(MVT::f64);
|
|
|
|
unsigned Tmp5 = MakeReg(MVT::f64);
|
|
|
|
unsigned Tmp6 = MakeReg(MVT::f64);
|
|
|
|
unsigned Tmp7 = MakeReg(MVT::f64);
|
|
|
|
unsigned Tmp8 = MakeReg(MVT::f64);
|
|
|
|
unsigned Tmp9 = MakeReg(MVT::f64);
|
|
|
|
|
|
|
|
BuildMI(BB, Alpha::STQ, 3).addReg(Tmp1).addFrameIndex(FrameIdxL).addReg(Alpha::F31);
|
2005-03-23 23:20:01 +08:00
|
|
|
BuildMI(BB, Alpha::STQ, 3).addReg(Tmp2).addFrameIndex(FrameIdxR).addReg(Alpha::F31);
|
2005-03-22 08:24:07 +08:00
|
|
|
BuildMI(BB, Alpha::LDT, 2, Tmp4).addFrameIndex(FrameIdxL).addReg(Alpha::F31);
|
|
|
|
BuildMI(BB, Alpha::LDT, 2, Tmp5).addFrameIndex(FrameIdxR).addReg(Alpha::F31);
|
|
|
|
BuildMI(BB, Alpha::CVTQT, 1, Tmp6).addReg(Tmp4);
|
|
|
|
BuildMI(BB, Alpha::CVTQT, 1, Tmp7).addReg(Tmp5);
|
|
|
|
BuildMI(BB, Alpha::DIVT, 2, Tmp8).addReg(Tmp6).addReg(Tmp7);
|
|
|
|
BuildMI(BB, Alpha::CVTTQ, 1, Tmp9).addReg(Tmp8);
|
|
|
|
BuildMI(BB, Alpha::STT, 3).addReg(Tmp9).addFrameIndex(FrameIdxF).addReg(Alpha::F31);
|
2005-03-23 23:20:01 +08:00
|
|
|
BuildMI(BB, Alpha::LDQ, 2, Result).addFrameIndex(FrameIdxF).addReg(Alpha::F31);
|
2005-03-22 08:24:07 +08:00
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
2005-01-29 07:17:54 +08:00
|
|
|
//Alpha has instructions for a bunch of signed 32 bit stuff
|
|
|
|
if( dyn_cast<MVTSDNode>(Node)->getExtraValueType() == MVT::i32)
|
2005-03-22 08:24:07 +08:00
|
|
|
{
|
2005-02-10 14:25:22 +08:00
|
|
|
switch (N.getOperand(0).getOpcode()) {
|
|
|
|
case ISD::ADD:
|
|
|
|
case ISD::SUB:
|
|
|
|
case ISD::MUL:
|
|
|
|
{
|
|
|
|
bool isAdd = N.getOperand(0).getOpcode() == ISD::ADD;
|
|
|
|
bool isMul = N.getOperand(0).getOpcode() == ISD::MUL;
|
|
|
|
//FIXME: first check for Scaled Adds and Subs!
|
|
|
|
if(N.getOperand(0).getOperand(1).getOpcode() == ISD::Constant &&
|
|
|
|
cast<ConstantSDNode>(N.getOperand(0).getOperand(1))->getValue() <= 255)
|
|
|
|
{ //Normal imm add/sub
|
|
|
|
Opc = isAdd ? Alpha::ADDLi : (isMul ? Alpha::MULLi : Alpha::SUBLi);
|
2005-02-13 05:11:17 +08:00
|
|
|
//if the value was really originally a i32, skip the up conversion
|
|
|
|
if (N.getOperand(0).getOperand(0).getOpcode() == ISD::SIGN_EXTEND_INREG &&
|
|
|
|
dyn_cast<MVTSDNode>(N.getOperand(0).getOperand(0).Val)
|
|
|
|
->getExtraValueType() == MVT::i32)
|
|
|
|
Tmp1 = SelectExpr(N.getOperand(0).getOperand(0).getOperand(0));
|
|
|
|
else
|
|
|
|
Tmp1 = SelectExpr(N.getOperand(0).getOperand(0));
|
2005-02-10 14:25:22 +08:00
|
|
|
Tmp2 = cast<ConstantSDNode>(N.getOperand(0).getOperand(1))->getValue();
|
|
|
|
BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ //Normal add/sub
|
|
|
|
Opc = isAdd ? Alpha::ADDL : (isMul ? Alpha::MULLi : Alpha::SUBL);
|
2005-02-13 05:11:17 +08:00
|
|
|
//if the value was really originally a i32, skip the up conversion
|
|
|
|
if (N.getOperand(0).getOperand(0).getOpcode() == ISD::SIGN_EXTEND_INREG &&
|
|
|
|
dyn_cast<MVTSDNode>(N.getOperand(0).getOperand(0).Val)
|
|
|
|
->getExtraValueType() == MVT::i32)
|
|
|
|
Tmp1 = SelectExpr(N.getOperand(0).getOperand(0).getOperand(0));
|
|
|
|
else
|
|
|
|
Tmp1 = SelectExpr(N.getOperand(0).getOperand(0));
|
|
|
|
//if the value was really originally a i32, skip the up conversion
|
|
|
|
if (N.getOperand(0).getOperand(1).getOpcode() == ISD::SIGN_EXTEND_INREG &&
|
|
|
|
dyn_cast<MVTSDNode>(N.getOperand(0).getOperand(1).Val)
|
|
|
|
->getExtraValueType() == MVT::i32)
|
|
|
|
Tmp2 = SelectExpr(N.getOperand(0).getOperand(1).getOperand(0));
|
|
|
|
else
|
|
|
|
Tmp2 = SelectExpr(N.getOperand(0).getOperand(1));
|
|
|
|
|
2005-02-10 14:25:22 +08:00
|
|
|
Tmp1 = SelectExpr(N.getOperand(0).getOperand(0));
|
|
|
|
Tmp2 = SelectExpr(N.getOperand(0).getOperand(1));
|
|
|
|
BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2);
|
2005-01-29 07:17:54 +08:00
|
|
|
}
|
2005-02-10 14:25:22 +08:00
|
|
|
return Result;
|
2005-01-29 07:17:54 +08:00
|
|
|
}
|
2005-03-03 01:23:03 +08:00
|
|
|
case ISD::SEXTLOAD:
|
|
|
|
//SelectionDag isn't deleting the signextend after sextloads
|
|
|
|
Reg = Result = SelectExpr(N.getOperand(0));
|
|
|
|
return Result;
|
2005-02-10 14:25:22 +08:00
|
|
|
default: break; //Fall Though;
|
|
|
|
}
|
|
|
|
} //Every thing else fall though too, including unhandled opcodes above
|
2005-01-23 07:41:55 +08:00
|
|
|
Tmp1 = SelectExpr(N.getOperand(0));
|
|
|
|
MVTSDNode* MVN = dyn_cast<MVTSDNode>(Node);
|
2005-01-27 05:54:09 +08:00
|
|
|
//std::cerr << "SrcT: " << MVN->getExtraValueType() << "\n";
|
2005-01-23 07:41:55 +08:00
|
|
|
switch(MVN->getExtraValueType())
|
2005-02-10 14:25:22 +08:00
|
|
|
{
|
|
|
|
default:
|
|
|
|
Node->dump();
|
|
|
|
assert(0 && "Sign Extend InReg not there yet");
|
|
|
|
break;
|
|
|
|
case MVT::i32:
|
2005-01-27 11:49:45 +08:00
|
|
|
{
|
2005-02-10 14:25:22 +08:00
|
|
|
BuildMI(BB, Alpha::ADDLi, 2, Result).addReg(Tmp1).addImm(0);
|
2005-01-27 11:49:45 +08:00
|
|
|
break;
|
|
|
|
}
|
2005-02-10 14:25:22 +08:00
|
|
|
case MVT::i16:
|
|
|
|
BuildMI(BB, Alpha::SEXTW, 1, Result).addReg(Tmp1);
|
|
|
|
break;
|
|
|
|
case MVT::i8:
|
|
|
|
BuildMI(BB, Alpha::SEXTB, 1, Result).addReg(Tmp1);
|
|
|
|
break;
|
2005-02-13 03:35:12 +08:00
|
|
|
case MVT::i1:
|
|
|
|
Tmp2 = MakeReg(MVT::i64);
|
|
|
|
BuildMI(BB, Alpha::ANDi, 2, Tmp2).addReg(Tmp1).addImm(1);
|
2005-02-13 04:42:09 +08:00
|
|
|
BuildMI(BB, Alpha::SUBQ, 2, Result).addReg(Alpha::F31).addReg(Tmp2);
|
2005-02-13 03:35:12 +08:00
|
|
|
break;
|
2005-02-10 14:25:22 +08:00
|
|
|
}
|
2005-01-23 07:41:55 +08:00
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
case ISD::ZERO_EXTEND_INREG:
|
|
|
|
{
|
|
|
|
Tmp1 = SelectExpr(N.getOperand(0));
|
|
|
|
MVTSDNode* MVN = dyn_cast<MVTSDNode>(Node);
|
2005-01-27 05:54:09 +08:00
|
|
|
//std::cerr << "SrcT: " << MVN->getExtraValueType() << "\n";
|
2005-01-23 07:41:55 +08:00
|
|
|
switch(MVN->getExtraValueType())
|
2005-02-10 14:25:22 +08:00
|
|
|
{
|
|
|
|
default:
|
|
|
|
Node->dump();
|
|
|
|
assert(0 && "Zero Extend InReg not there yet");
|
|
|
|
break;
|
|
|
|
case MVT::i32: Tmp2 = 0xf0; break;
|
|
|
|
case MVT::i16: Tmp2 = 0xfc; break;
|
|
|
|
case MVT::i8: Tmp2 = 0xfe; break;
|
|
|
|
case MVT::i1: //handle this one special
|
|
|
|
BuildMI(BB, Alpha::ANDi, 2, Result).addReg(Tmp1).addImm(1);
|
|
|
|
return Result;
|
|
|
|
}
|
2005-01-25 08:35:34 +08:00
|
|
|
BuildMI(BB, Alpha::ZAPi, 2, Result).addReg(Tmp1).addImm(Tmp2);
|
2005-01-27 11:49:45 +08:00
|
|
|
return Result;
|
2005-01-23 07:41:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
case ISD::SETCC:
|
2005-01-27 11:49:45 +08:00
|
|
|
{
|
|
|
|
if (SetCCSDNode *SetCC = dyn_cast<SetCCSDNode>(Node)) {
|
|
|
|
if (MVT::isInteger(SetCC->getOperand(0).getValueType())) {
|
|
|
|
bool isConst1 = false;
|
|
|
|
bool isConst2 = false;
|
|
|
|
int dir;
|
2005-02-05 21:19:12 +08:00
|
|
|
|
2005-01-27 11:49:45 +08:00
|
|
|
//Tmp1 = SelectExpr(N.getOperand(0));
|
|
|
|
if(N.getOperand(0).getOpcode() == ISD::Constant &&
|
|
|
|
cast<ConstantSDNode>(N.getOperand(0))->getValue() <= 255)
|
|
|
|
isConst1 = true;
|
|
|
|
if(N.getOperand(1).getOpcode() == ISD::Constant &&
|
|
|
|
cast<ConstantSDNode>(N.getOperand(1))->getValue() <= 255)
|
|
|
|
isConst2 = true;
|
|
|
|
|
|
|
|
switch (SetCC->getCondition()) {
|
|
|
|
default: Node->dump(); assert(0 && "Unknown integer comparison!");
|
|
|
|
case ISD::SETEQ: Opc = Alpha::CMPEQ; dir=0; break;
|
2005-02-10 14:25:22 +08:00
|
|
|
case ISD::SETLT:
|
|
|
|
Opc = isConst2 ? Alpha::CMPLTi : Alpha::CMPLT; dir = 1; break;
|
|
|
|
case ISD::SETLE:
|
|
|
|
Opc = isConst2 ? Alpha::CMPLEi : Alpha::CMPLE; dir = 1; break;
|
|
|
|
case ISD::SETGT:
|
|
|
|
Opc = isConst1 ? Alpha::CMPLTi : Alpha::CMPLT; dir = 2; break;
|
|
|
|
case ISD::SETGE:
|
|
|
|
Opc = isConst1 ? Alpha::CMPLEi : Alpha::CMPLE; dir = 2; break;
|
|
|
|
case ISD::SETULT:
|
|
|
|
Opc = isConst2 ? Alpha::CMPULTi : Alpha::CMPULT; dir = 1; break;
|
|
|
|
case ISD::SETUGT:
|
|
|
|
Opc = isConst1 ? Alpha::CMPULTi : Alpha::CMPULT; dir = 2; break;
|
|
|
|
case ISD::SETULE:
|
|
|
|
Opc = isConst2 ? Alpha::CMPULEi : Alpha::CMPULE; dir = 1; break;
|
|
|
|
case ISD::SETUGE:
|
|
|
|
Opc = isConst1 ? Alpha::CMPULEi : Alpha::CMPULE; dir = 2; break;
|
2005-01-27 15:50:35 +08:00
|
|
|
case ISD::SETNE: {//Handle this one special
|
|
|
|
//std::cerr << "Alpha does not have a setne.\n";
|
|
|
|
//abort();
|
|
|
|
Tmp1 = SelectExpr(N.getOperand(0));
|
|
|
|
Tmp2 = SelectExpr(N.getOperand(1));
|
|
|
|
Tmp3 = MakeReg(MVT::i64);
|
|
|
|
BuildMI(BB, Alpha::CMPEQ, 2, Tmp3).addReg(Tmp1).addReg(Tmp2);
|
2005-02-08 08:40:03 +08:00
|
|
|
//Remeber we have the Inv for this CC
|
|
|
|
CCInvMap[N] = Tmp3;
|
2005-01-27 15:50:35 +08:00
|
|
|
//and invert
|
2005-01-29 07:17:54 +08:00
|
|
|
BuildMI(BB, Alpha::CMPEQ, 2, Result).addReg(Alpha::R31).addReg(Tmp3);
|
2005-01-27 15:50:35 +08:00
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
}
|
2005-01-27 11:49:45 +08:00
|
|
|
if (dir == 1) {
|
|
|
|
Tmp1 = SelectExpr(N.getOperand(0));
|
|
|
|
if (isConst2) {
|
|
|
|
Tmp2 = cast<ConstantSDNode>(N.getOperand(1))->getValue();
|
|
|
|
BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2);
|
|
|
|
} else {
|
|
|
|
Tmp2 = SelectExpr(N.getOperand(1));
|
|
|
|
BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2);
|
|
|
|
}
|
|
|
|
} else if (dir == 2) {
|
|
|
|
Tmp1 = SelectExpr(N.getOperand(1));
|
2005-01-28 22:06:46 +08:00
|
|
|
if (isConst1) {
|
2005-01-27 11:49:45 +08:00
|
|
|
Tmp2 = cast<ConstantSDNode>(N.getOperand(0))->getValue();
|
|
|
|
BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2);
|
|
|
|
} else {
|
|
|
|
Tmp2 = SelectExpr(N.getOperand(0));
|
|
|
|
BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2);
|
|
|
|
}
|
|
|
|
} else { //dir == 0
|
|
|
|
if (isConst1) {
|
|
|
|
Tmp1 = cast<ConstantSDNode>(N.getOperand(0))->getValue();
|
|
|
|
Tmp2 = SelectExpr(N.getOperand(1));
|
|
|
|
BuildMI(BB, Alpha::CMPEQi, 2, Result).addReg(Tmp2).addImm(Tmp1);
|
|
|
|
} else if (isConst2) {
|
|
|
|
Tmp1 = SelectExpr(N.getOperand(0));
|
|
|
|
Tmp2 = cast<ConstantSDNode>(N.getOperand(1))->getValue();
|
|
|
|
BuildMI(BB, Alpha::CMPEQi, 2, Result).addReg(Tmp1).addImm(Tmp2);
|
|
|
|
} else {
|
|
|
|
Tmp1 = SelectExpr(N.getOperand(0));
|
|
|
|
Tmp2 = SelectExpr(N.getOperand(1));
|
|
|
|
BuildMI(BB, Alpha::CMPEQ, 2, Result).addReg(Tmp1).addReg(Tmp2);
|
|
|
|
}
|
2005-02-06 00:41:03 +08:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//assert(SetCC->getOperand(0).getValueType() != MVT::f32 && "SetCC f32 should have been promoted");
|
|
|
|
bool rev = false;
|
|
|
|
bool inv = false;
|
|
|
|
|
|
|
|
switch (SetCC->getCondition()) {
|
|
|
|
default: Node->dump(); assert(0 && "Unknown FP comparison!");
|
|
|
|
case ISD::SETEQ: Opc = Alpha::CMPTEQ; break;
|
|
|
|
case ISD::SETLT: Opc = Alpha::CMPTLT; break;
|
|
|
|
case ISD::SETLE: Opc = Alpha::CMPTLE; break;
|
|
|
|
case ISD::SETGT: Opc = Alpha::CMPTLT; rev = true; break;
|
|
|
|
case ISD::SETGE: Opc = Alpha::CMPTLE; rev = true; break;
|
|
|
|
case ISD::SETNE: Opc = Alpha::CMPTEQ; inv = true; break;
|
|
|
|
}
|
|
|
|
|
2005-03-15 03:23:45 +08:00
|
|
|
//FIXME: check for constant 0.0
|
|
|
|
ConstantFPSDNode *CN;
|
|
|
|
if ((CN = dyn_cast<ConstantFPSDNode>(SetCC->getOperand(0)))
|
|
|
|
&& (CN->isExactlyValue(+0.0) || CN->isExactlyValue(-0.0)))
|
|
|
|
Tmp1 = Alpha::F31;
|
|
|
|
else
|
|
|
|
Tmp1 = SelectExpr(N.getOperand(0));
|
|
|
|
|
|
|
|
if ((CN = dyn_cast<ConstantFPSDNode>(SetCC->getOperand(1)))
|
|
|
|
&& (CN->isExactlyValue(+0.0) || CN->isExactlyValue(-0.0)))
|
|
|
|
Tmp2 = Alpha::F31;
|
|
|
|
else
|
|
|
|
Tmp2 = SelectExpr(N.getOperand(1));
|
|
|
|
|
2005-02-06 00:41:03 +08:00
|
|
|
//Can only compare doubles, and dag won't promote for me
|
|
|
|
if (SetCC->getOperand(0).getValueType() == MVT::f32)
|
2005-02-10 14:25:22 +08:00
|
|
|
{
|
2005-02-23 05:59:48 +08:00
|
|
|
//assert(0 && "Setcc On float?\n");
|
|
|
|
std::cerr << "Setcc on float!\n";
|
2005-02-10 14:25:22 +08:00
|
|
|
Tmp3 = MakeReg(MVT::f64);
|
|
|
|
BuildMI(BB, Alpha::CVTST, 1, Tmp3).addReg(Tmp1);
|
|
|
|
Tmp1 = Tmp3;
|
|
|
|
}
|
2005-02-06 00:41:03 +08:00
|
|
|
if (SetCC->getOperand(1).getValueType() == MVT::f32)
|
2005-02-10 14:25:22 +08:00
|
|
|
{
|
2005-02-23 05:59:48 +08:00
|
|
|
//assert (0 && "Setcc On float?\n");
|
|
|
|
std::cerr << "Setcc on float!\n";
|
2005-02-10 14:25:22 +08:00
|
|
|
Tmp3 = MakeReg(MVT::f64);
|
|
|
|
BuildMI(BB, Alpha::CVTST, 1, Tmp3).addReg(Tmp2);
|
2005-02-14 13:41:43 +08:00
|
|
|
Tmp2 = Tmp3;
|
2005-02-10 14:25:22 +08:00
|
|
|
}
|
2005-02-05 21:19:12 +08:00
|
|
|
|
2005-02-06 00:41:03 +08:00
|
|
|
if (rev) std::swap(Tmp1, Tmp2);
|
|
|
|
Tmp3 = MakeReg(MVT::f64);
|
|
|
|
//do the comparison
|
|
|
|
BuildMI(BB, Opc, 2, Tmp3).addReg(Tmp1).addReg(Tmp2);
|
|
|
|
|
|
|
|
//now arrange for Result (int) to have a 1 or 0
|
2005-03-22 08:24:07 +08:00
|
|
|
unsigned Tmp4 = MakeReg(MVT::i64);
|
|
|
|
BuildMI(BB, Alpha::ADDQi, 2, Tmp4).addReg(Alpha::R31).addImm(1);
|
|
|
|
Opc = inv?Alpha::CMOVNEi_FP:Alpha::CMOVEQi_FP;
|
|
|
|
BuildMI(BB, Opc, 3, Result).addReg(Tmp4).addImm(0).addReg(Tmp3);
|
2005-03-15 03:23:45 +08:00
|
|
|
|
|
|
|
// // Spill the FP to memory and reload it from there.
|
|
|
|
// unsigned Size = MVT::getSizeInBits(MVT::f64)/8;
|
|
|
|
// MachineFunction *F = BB->getParent();
|
|
|
|
// int FrameIdx = F->getFrameInfo()->CreateStackObject(Size, 8);
|
|
|
|
// unsigned Tmp4 = MakeReg(MVT::f64);
|
|
|
|
// BuildMI(BB, Alpha::CVTTQ, 1, Tmp4).addReg(Tmp3);
|
|
|
|
// BuildMI(BB, Alpha::STT, 3).addReg(Tmp4).addFrameIndex(FrameIdx).addReg(Alpha::F31);
|
|
|
|
// unsigned Tmp5 = MakeReg(MVT::i64);
|
|
|
|
// BuildMI(BB, Alpha::LDQ, 2, Tmp5).addFrameIndex(FrameIdx).addReg(Alpha::F31);
|
2005-02-06 00:41:03 +08:00
|
|
|
|
2005-03-15 03:23:45 +08:00
|
|
|
// //now, set result based on Tmp5
|
|
|
|
// //Set Tmp6 if fp cmp was false
|
|
|
|
// unsigned Tmp6 = MakeReg(MVT::i64);
|
|
|
|
// BuildMI(BB, Alpha::CMPEQ, 2, Tmp6).addReg(Tmp5).addReg(Alpha::R31);
|
|
|
|
// //and invert
|
|
|
|
// BuildMI(BB, Alpha::CMPEQ, 2, Result).addReg(Tmp6).addReg(Alpha::R31);
|
2005-02-06 00:41:03 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// Node->dump();
|
|
|
|
// assert(0 && "Not a setcc in setcc");
|
|
|
|
// }
|
2005-01-23 07:41:55 +08:00
|
|
|
}
|
2005-01-27 11:49:45 +08:00
|
|
|
return Result;
|
2005-01-23 07:41:55 +08:00
|
|
|
}
|
2005-01-27 11:49:45 +08:00
|
|
|
|
2005-01-23 07:41:55 +08:00
|
|
|
case ISD::CopyFromReg:
|
|
|
|
{
|
2005-01-28 14:57:18 +08:00
|
|
|
// Make sure we generate both values.
|
2005-01-29 07:17:54 +08:00
|
|
|
if (Result != notIn)
|
|
|
|
ExprMap[N.getValue(1)] = notIn; // Generate the token
|
2005-01-28 14:57:18 +08:00
|
|
|
else
|
2005-01-23 07:41:55 +08:00
|
|
|
Result = ExprMap[N.getValue(0)] = MakeReg(N.getValue(0).getValueType());
|
2005-01-28 14:57:18 +08:00
|
|
|
|
2005-01-23 07:41:55 +08:00
|
|
|
SDOperand Chain = N.getOperand(0);
|
|
|
|
|
|
|
|
Select(Chain);
|
|
|
|
unsigned r = dyn_cast<RegSDNode>(Node)->getReg();
|
|
|
|
//std::cerr << "CopyFromReg " << Result << " = " << r << "\n";
|
|
|
|
BuildMI(BB, Alpha::BIS, 2, Result).addReg(r).addReg(r);
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
2005-01-25 03:44:07 +08:00
|
|
|
//Most of the plain arithmetic and logic share the same form, and the same
|
|
|
|
//constant immediate test
|
|
|
|
case ISD::AND:
|
|
|
|
case ISD::OR:
|
|
|
|
case ISD::XOR:
|
|
|
|
case ISD::SHL:
|
|
|
|
case ISD::SRL:
|
2005-01-29 23:42:07 +08:00
|
|
|
case ISD::SRA:
|
2005-01-25 03:44:07 +08:00
|
|
|
case ISD::MUL:
|
2005-01-28 14:57:18 +08:00
|
|
|
assert (DestType == MVT::i64 && "Only do arithmetic on i64s!");
|
|
|
|
if(N.getOperand(1).getOpcode() == ISD::Constant &&
|
|
|
|
cast<ConstantSDNode>(N.getOperand(1))->getValue() <= 255)
|
2005-02-10 14:25:22 +08:00
|
|
|
{
|
|
|
|
switch(opcode) {
|
|
|
|
case ISD::AND: Opc = Alpha::ANDi; break;
|
|
|
|
case ISD::OR: Opc = Alpha::BISi; break;
|
|
|
|
case ISD::XOR: Opc = Alpha::XORi; break;
|
|
|
|
case ISD::SHL: Opc = Alpha::SLi; break;
|
|
|
|
case ISD::SRL: Opc = Alpha::SRLi; break;
|
|
|
|
case ISD::SRA: Opc = Alpha::SRAi; break;
|
|
|
|
case ISD::MUL: Opc = Alpha::MULQi; break;
|
|
|
|
};
|
|
|
|
Tmp1 = SelectExpr(N.getOperand(0));
|
|
|
|
Tmp2 = cast<ConstantSDNode>(N.getOperand(1))->getValue();
|
|
|
|
BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2);
|
|
|
|
} else {
|
|
|
|
switch(opcode) {
|
|
|
|
case ISD::AND: Opc = Alpha::AND; break;
|
|
|
|
case ISD::OR: Opc = Alpha::BIS; break;
|
|
|
|
case ISD::XOR: Opc = Alpha::XOR; break;
|
|
|
|
case ISD::SHL: Opc = Alpha::SL; break;
|
|
|
|
case ISD::SRL: Opc = Alpha::SRL; break;
|
|
|
|
case ISD::SRA: Opc = Alpha::SRA; break;
|
|
|
|
case ISD::MUL: Opc = Alpha::MULQ; break;
|
|
|
|
};
|
|
|
|
Tmp1 = SelectExpr(N.getOperand(0));
|
|
|
|
Tmp2 = SelectExpr(N.getOperand(1));
|
|
|
|
BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2);
|
|
|
|
}
|
2005-01-27 05:54:09 +08:00
|
|
|
return Result;
|
2005-01-28 14:57:18 +08:00
|
|
|
|
2005-01-27 05:54:09 +08:00
|
|
|
case ISD::ADD:
|
|
|
|
case ISD::SUB:
|
|
|
|
{
|
2005-01-28 14:57:18 +08:00
|
|
|
bool isAdd = opcode == ISD::ADD;
|
|
|
|
|
|
|
|
//FIXME: first check for Scaled Adds and Subs!
|
|
|
|
if(N.getOperand(1).getOpcode() == ISD::Constant &&
|
|
|
|
cast<ConstantSDNode>(N.getOperand(1))->getValue() <= 255)
|
2005-02-10 14:25:22 +08:00
|
|
|
{ //Normal imm add/sub
|
|
|
|
Opc = isAdd ? Alpha::ADDQi : Alpha::SUBQi;
|
|
|
|
Tmp1 = SelectExpr(N.getOperand(0));
|
|
|
|
Tmp2 = cast<ConstantSDNode>(N.getOperand(1))->getValue();
|
|
|
|
BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2);
|
|
|
|
}
|
2005-01-28 14:57:18 +08:00
|
|
|
else if(N.getOperand(1).getOpcode() == ISD::Constant &&
|
2005-03-03 01:23:03 +08:00
|
|
|
(cast<ConstantSDNode>(N.getOperand(1))->getValue() <= 32767 ||
|
|
|
|
(long)cast<ConstantSDNode>(N.getOperand(1))->getValue() >= -32767))
|
|
|
|
{ //LDA
|
2005-02-10 14:25:22 +08:00
|
|
|
Tmp1 = SelectExpr(N.getOperand(0));
|
2005-03-03 01:23:03 +08:00
|
|
|
Tmp2 = (long)cast<ConstantSDNode>(N.getOperand(1))->getValue();
|
2005-02-10 14:25:22 +08:00
|
|
|
if (!isAdd)
|
|
|
|
Tmp2 = -Tmp2;
|
|
|
|
BuildMI(BB, Alpha::LDA, 2, Result).addImm(Tmp2).addReg(Tmp1);
|
|
|
|
} else {
|
|
|
|
//Normal add/sub
|
|
|
|
Opc = isAdd ? Alpha::ADDQ : Alpha::SUBQ;
|
|
|
|
Tmp1 = SelectExpr(N.getOperand(0));
|
|
|
|
Tmp2 = SelectExpr(N.getOperand(1));
|
|
|
|
BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2);
|
|
|
|
}
|
2005-01-27 05:54:09 +08:00
|
|
|
return Result;
|
|
|
|
}
|
2005-01-23 07:41:55 +08:00
|
|
|
|
2005-03-22 08:24:07 +08:00
|
|
|
case ISD::SDIV:
|
2005-01-23 07:41:55 +08:00
|
|
|
case ISD::UREM:
|
2005-01-26 09:24:38 +08:00
|
|
|
case ISD::SREM:
|
|
|
|
case ISD::UDIV:
|
2005-01-28 14:57:18 +08:00
|
|
|
//FIXME: alpha really doesn't support any of these operations,
|
|
|
|
// the ops are expanded into special library calls with
|
|
|
|
// special calling conventions
|
2005-02-10 14:25:22 +08:00
|
|
|
//Restore GP because it is a call after all...
|
2005-01-28 14:57:18 +08:00
|
|
|
switch(opcode) {
|
2005-02-26 06:55:15 +08:00
|
|
|
case ISD::UREM: Opc = Alpha::REMQU; break;
|
|
|
|
case ISD::SREM: Opc = Alpha::REMQ; break;
|
|
|
|
case ISD::UDIV: Opc = Alpha::DIVQU; break;
|
|
|
|
case ISD::SDIV: Opc = Alpha::DIVQ; break;
|
2005-01-27 05:54:09 +08:00
|
|
|
}
|
2005-01-23 07:41:55 +08:00
|
|
|
Tmp1 = SelectExpr(N.getOperand(0));
|
|
|
|
Tmp2 = SelectExpr(N.getOperand(1));
|
2005-03-05 04:09:23 +08:00
|
|
|
//set up regs explicitly (helps Reg alloc)
|
|
|
|
BuildMI(BB, Alpha::BIS, 2, Alpha::R24).addReg(Tmp1).addReg(Tmp1);
|
|
|
|
BuildMI(BB, Alpha::BIS, 2, Alpha::R25).addReg(Tmp2).addReg(Tmp2);
|
2005-02-26 06:55:15 +08:00
|
|
|
AlphaLowering.restoreGP(BB);
|
2005-03-05 04:09:23 +08:00
|
|
|
BuildMI(BB, Opc, 2).addReg(Alpha::R24).addReg(Alpha::R25);
|
|
|
|
BuildMI(BB, Alpha::BIS, 2, Result).addReg(Alpha::R27).addReg(Alpha::R27);
|
2005-01-23 07:41:55 +08:00
|
|
|
return Result;
|
2005-01-31 09:44:26 +08:00
|
|
|
|
2005-02-02 04:40:27 +08:00
|
|
|
case ISD::FP_TO_UINT:
|
2005-01-31 09:44:26 +08:00
|
|
|
case ISD::FP_TO_SINT:
|
2005-02-10 14:25:22 +08:00
|
|
|
{
|
2005-01-31 09:44:26 +08:00
|
|
|
assert (DestType == MVT::i64 && "only quads can be loaded to");
|
|
|
|
MVT::ValueType SrcType = N.getOperand(0).getValueType();
|
2005-02-07 13:55:55 +08:00
|
|
|
assert (SrcType == MVT::f32 || SrcType == MVT::f64);
|
2005-01-31 09:44:26 +08:00
|
|
|
Tmp1 = SelectExpr(N.getOperand(0)); // Get the operand register
|
|
|
|
|
|
|
|
//The hard way:
|
|
|
|
// Spill the integer to memory and reload it from there.
|
|
|
|
unsigned Size = MVT::getSizeInBits(MVT::f64)/8;
|
|
|
|
MachineFunction *F = BB->getParent();
|
|
|
|
int FrameIdx = F->getFrameInfo()->CreateStackObject(Size, 8);
|
|
|
|
|
|
|
|
//CVTTQ STT LDQ
|
|
|
|
//CVTST CVTTQ STT LDQ
|
|
|
|
if (SrcType == MVT::f32)
|
2005-02-10 14:25:22 +08:00
|
|
|
{
|
|
|
|
Tmp2 = MakeReg(MVT::f64);
|
|
|
|
BuildMI(BB, Alpha::CVTST, 1, Tmp2).addReg(Tmp1);
|
|
|
|
Tmp1 = Tmp2;
|
|
|
|
}
|
2005-01-31 09:44:26 +08:00
|
|
|
Tmp2 = MakeReg(MVT::f64);
|
|
|
|
BuildMI(BB, Alpha::CVTTQ, 1, Tmp2).addReg(Tmp1);
|
|
|
|
BuildMI(BB, Alpha::STT, 3).addReg(Tmp2).addFrameIndex(FrameIdx).addReg(Alpha::F31);
|
|
|
|
BuildMI(BB, Alpha::LDQ, 2, Result).addFrameIndex(FrameIdx).addReg(Alpha::F31);
|
|
|
|
|
|
|
|
return Result;
|
2005-02-10 14:25:22 +08:00
|
|
|
}
|
2005-01-27 05:54:09 +08:00
|
|
|
|
2005-02-10 14:25:22 +08:00
|
|
|
// // case ISD::FP_TO_UINT:
|
2005-01-27 05:54:09 +08:00
|
|
|
|
2005-01-23 07:41:55 +08:00
|
|
|
case ISD::SELECT:
|
|
|
|
{
|
2005-03-22 08:24:07 +08:00
|
|
|
//FIXME: look at parent to decide if intCC can be folded, or if setCC(FP) and can save stack use
|
2005-02-02 04:40:27 +08:00
|
|
|
Tmp1 = SelectExpr(N.getOperand(0)); //Cond
|
2005-01-23 07:41:55 +08:00
|
|
|
Tmp2 = SelectExpr(N.getOperand(1)); //Use if TRUE
|
|
|
|
Tmp3 = SelectExpr(N.getOperand(2)); //Use if FALSE
|
|
|
|
// Get the condition into the zero flag.
|
2005-02-02 04:40:27 +08:00
|
|
|
BuildMI(BB, Alpha::CMOVEQ, 2, Result).addReg(Tmp2).addReg(Tmp3).addReg(Tmp1);
|
2005-01-23 07:41:55 +08:00
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
|
|
|
case ISD::Constant:
|
|
|
|
{
|
2005-03-30 03:24:04 +08:00
|
|
|
int64_t val = (int64_t)cast<ConstantSDNode>(N)->getValue();
|
2005-03-12 01:48:05 +08:00
|
|
|
if (val <= IMM_HIGH && val >= IMM_LOW) {
|
|
|
|
BuildMI(BB, Alpha::LDA, 2, Result).addImm(val).addReg(Alpha::R31);
|
|
|
|
}
|
|
|
|
else if (val <= (int64_t)IMM_HIGH + (int64_t)IMM_HIGH * (int64_t)IMM_MULT &&
|
|
|
|
val >= (int64_t)IMM_LOW + (int64_t)IMM_LOW * (int64_t)IMM_MULT) {
|
|
|
|
Tmp1 = MakeReg(MVT::i64);
|
|
|
|
BuildMI(BB, Alpha::LDAH, 2, Tmp1).addImm(getUpper16(val)).addReg(Alpha::R31);
|
|
|
|
BuildMI(BB, Alpha::LDA, 2, Result).addImm(getLower16(val)).addReg(Tmp1);
|
|
|
|
}
|
2005-02-10 14:25:22 +08:00
|
|
|
else {
|
|
|
|
MachineConstantPool *CP = BB->getParent()->getConstantPool();
|
|
|
|
ConstantUInt *C = ConstantUInt::get(Type::getPrimitiveType(Type::ULongTyID) , val);
|
|
|
|
unsigned CPI = CP->getConstantPoolIndex(C);
|
|
|
|
AlphaLowering.restoreGP(BB);
|
|
|
|
BuildMI(BB, Alpha::LDQ_SYM, 1, Result).addConstantPoolIndex(CPI);
|
|
|
|
}
|
|
|
|
return Result;
|
2005-01-23 07:41:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ISel::Select(SDOperand N) {
|
|
|
|
unsigned Tmp1, Tmp2, Opc;
|
2005-02-08 07:02:23 +08:00
|
|
|
unsigned opcode = N.getOpcode();
|
2005-01-23 07:41:55 +08:00
|
|
|
|
2005-03-24 12:39:54 +08:00
|
|
|
if (!ExprMap.insert(std::make_pair(N, notIn)).second)
|
2005-01-28 22:06:46 +08:00
|
|
|
return; // Already selected.
|
2005-01-23 07:41:55 +08:00
|
|
|
|
|
|
|
SDNode *Node = N.Val;
|
2005-02-08 07:02:23 +08:00
|
|
|
|
|
|
|
switch (opcode) {
|
2005-01-23 07:41:55 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
Node->dump(); std::cerr << "\n";
|
|
|
|
assert(0 && "Node not handled yet!");
|
|
|
|
|
|
|
|
case ISD::BRCOND: {
|
2005-02-08 08:40:03 +08:00
|
|
|
SelectBranchCC(N);
|
2005-01-23 07:41:55 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case ISD::BR: {
|
|
|
|
MachineBasicBlock *Dest =
|
|
|
|
cast<BasicBlockSDNode>(N.getOperand(1))->getBasicBlock();
|
|
|
|
|
|
|
|
Select(N.getOperand(0));
|
|
|
|
BuildMI(BB, Alpha::BR, 1, Alpha::R31).addMBB(Dest);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case ISD::ImplicitDef:
|
|
|
|
Select(N.getOperand(0));
|
|
|
|
BuildMI(BB, Alpha::IDEF, 0, cast<RegSDNode>(N)->getReg());
|
|
|
|
return;
|
|
|
|
|
|
|
|
case ISD::EntryToken: return; // Noop
|
|
|
|
|
|
|
|
case ISD::TokenFactor:
|
|
|
|
for (unsigned i = 0, e = Node->getNumOperands(); i != e; ++i)
|
|
|
|
Select(Node->getOperand(i));
|
|
|
|
|
|
|
|
//N.Val->dump(); std::cerr << "\n";
|
|
|
|
//assert(0 && "Node not handled yet!");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
case ISD::CopyToReg:
|
|
|
|
Select(N.getOperand(0));
|
|
|
|
Tmp1 = SelectExpr(N.getOperand(1));
|
|
|
|
Tmp2 = cast<RegSDNode>(N)->getReg();
|
|
|
|
|
|
|
|
if (Tmp1 != Tmp2) {
|
2005-02-10 14:25:22 +08:00
|
|
|
if (N.getOperand(1).getValueType() == MVT::f64 ||
|
|
|
|
N.getOperand(1).getValueType() == MVT::f32)
|
2005-02-07 14:31:44 +08:00
|
|
|
BuildMI(BB, Alpha::CPYS, 2, Tmp2).addReg(Tmp1).addReg(Tmp1);
|
|
|
|
else
|
|
|
|
BuildMI(BB, Alpha::BIS, 2, Tmp2).addReg(Tmp1).addReg(Tmp1);
|
2005-01-23 07:41:55 +08:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
|
2005-02-10 14:25:22 +08:00
|
|
|
case ISD::RET:
|
|
|
|
switch (N.getNumOperands()) {
|
|
|
|
default:
|
|
|
|
std::cerr << N.getNumOperands() << "\n";
|
|
|
|
for (unsigned i = 0; i < N.getNumOperands(); ++i)
|
|
|
|
std::cerr << N.getOperand(i).getValueType() << "\n";
|
|
|
|
Node->dump();
|
|
|
|
assert(0 && "Unknown return instruction!");
|
|
|
|
case 2:
|
|
|
|
Select(N.getOperand(0));
|
|
|
|
Tmp1 = SelectExpr(N.getOperand(1));
|
|
|
|
switch (N.getOperand(1).getValueType()) {
|
|
|
|
default: Node->dump();
|
|
|
|
assert(0 && "All other types should have been promoted!!");
|
|
|
|
case MVT::f64:
|
|
|
|
case MVT::f32:
|
|
|
|
BuildMI(BB, Alpha::CPYS, 2, Alpha::F0).addReg(Tmp1).addReg(Tmp1);
|
|
|
|
break;
|
|
|
|
case MVT::i32:
|
|
|
|
case MVT::i64:
|
|
|
|
BuildMI(BB, Alpha::BIS, 2, Alpha::R0).addReg(Tmp1).addReg(Tmp1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
Select(N.getOperand(0));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//Tmp2 = AlphaLowering.getRetAddr();
|
|
|
|
//BuildMI(BB, Alpha::BIS, 2, Alpha::R26).addReg(Tmp2).addReg(Tmp2);
|
|
|
|
BuildMI(BB, Alpha::RETURN, 0); // Just emit a 'ret' instruction
|
|
|
|
return;
|
2005-01-23 07:41:55 +08:00
|
|
|
|
2005-02-07 13:18:02 +08:00
|
|
|
case ISD::TRUNCSTORE:
|
2005-01-23 07:41:55 +08:00
|
|
|
case ISD::STORE:
|
2005-02-03 01:32:39 +08:00
|
|
|
{
|
2005-02-06 23:40:40 +08:00
|
|
|
SDOperand Chain = N.getOperand(0);
|
|
|
|
SDOperand Value = N.getOperand(1);
|
|
|
|
SDOperand Address = N.getOperand(2);
|
|
|
|
Select(Chain);
|
|
|
|
|
|
|
|
Tmp1 = SelectExpr(Value); //value
|
2005-02-08 07:02:23 +08:00
|
|
|
|
|
|
|
if (opcode == ISD::STORE) {
|
|
|
|
switch(Value.getValueType()) {
|
|
|
|
default: assert(0 && "unknown Type in store");
|
|
|
|
case MVT::i64: Opc = Alpha::STQ; break;
|
|
|
|
case MVT::f64: Opc = Alpha::STT; break;
|
|
|
|
case MVT::f32: Opc = Alpha::STS; break;
|
|
|
|
}
|
|
|
|
} else { //ISD::TRUNCSTORE
|
|
|
|
switch(cast<MVTSDNode>(Node)->getExtraValueType()) {
|
|
|
|
default: assert(0 && "unknown Type in store");
|
|
|
|
case MVT::i1: //FIXME: DAG does not promote this load
|
|
|
|
case MVT::i8: Opc = Alpha::STB; break;
|
|
|
|
case MVT::i16: Opc = Alpha::STW; break;
|
|
|
|
case MVT::i32: Opc = Alpha::STL; break;
|
|
|
|
}
|
2005-02-07 00:22:15 +08:00
|
|
|
}
|
2005-02-08 07:02:23 +08:00
|
|
|
|
2005-02-06 23:40:40 +08:00
|
|
|
if (Address.getOpcode() == ISD::GlobalAddress)
|
2005-02-10 14:25:22 +08:00
|
|
|
{
|
|
|
|
AlphaLowering.restoreGP(BB);
|
|
|
|
Opc = GetSymVersion(Opc);
|
|
|
|
BuildMI(BB, Opc, 2).addReg(Tmp1).addGlobalAddress(cast<GlobalAddressSDNode>(Address)->getGlobal());
|
|
|
|
}
|
2005-02-07 13:07:00 +08:00
|
|
|
else if(Address.getOpcode() == ISD::FrameIndex)
|
2005-02-10 14:25:22 +08:00
|
|
|
{
|
2005-02-23 05:59:48 +08:00
|
|
|
BuildMI(BB, Opc, 3).addReg(Tmp1)
|
|
|
|
.addFrameIndex(cast<FrameIndexSDNode>(Address)->getIndex())
|
|
|
|
.addReg(Alpha::F31);
|
2005-02-10 14:25:22 +08:00
|
|
|
}
|
2005-02-03 01:32:39 +08:00
|
|
|
else
|
2005-02-10 14:25:22 +08:00
|
|
|
{
|
|
|
|
long offset;
|
|
|
|
SelectAddr(Address, Tmp2, offset);
|
|
|
|
BuildMI(BB, Opc, 3).addReg(Tmp1).addImm(offset).addReg(Tmp2);
|
|
|
|
}
|
2005-02-03 01:32:39 +08:00
|
|
|
return;
|
|
|
|
}
|
2005-01-23 07:41:55 +08:00
|
|
|
|
|
|
|
case ISD::EXTLOAD:
|
|
|
|
case ISD::SEXTLOAD:
|
|
|
|
case ISD::ZEXTLOAD:
|
|
|
|
case ISD::LOAD:
|
|
|
|
case ISD::CopyFromReg:
|
|
|
|
case ISD::CALL:
|
2005-02-23 05:59:48 +08:00
|
|
|
case ISD::DYNAMIC_STACKALLOC:
|
2005-01-28 22:06:46 +08:00
|
|
|
ExprMap.erase(N);
|
2005-01-23 07:41:55 +08:00
|
|
|
SelectExpr(N);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case ISD::ADJCALLSTACKDOWN:
|
|
|
|
case ISD::ADJCALLSTACKUP:
|
|
|
|
Select(N.getOperand(0));
|
|
|
|
Tmp1 = cast<ConstantSDNode>(N.getOperand(1))->getValue();
|
|
|
|
|
|
|
|
Opc = N.getOpcode() == ISD::ADJCALLSTACKDOWN ? Alpha::ADJUSTSTACKDOWN :
|
|
|
|
Alpha::ADJUSTSTACKUP;
|
|
|
|
BuildMI(BB, Opc, 1).addImm(Tmp1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
assert(0 && "Should not be reached!");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// createAlphaPatternInstructionSelector - This pass converts an LLVM function
|
|
|
|
/// into a machine code representation using pattern matching and a machine
|
|
|
|
/// description file.
|
|
|
|
///
|
|
|
|
FunctionPass *llvm::createAlphaPatternInstructionSelector(TargetMachine &TM) {
|
|
|
|
return new ISel(TM);
|
|
|
|
}
|