diff options
author | Dan Gohman <gohman@apple.com> | 2011-10-27 22:56:32 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2011-10-27 22:56:32 +0000 |
commit | 33ba8b0e96acde0d8ab1ffc565a5ef4c8b6b6ac2 (patch) | |
tree | 19356b63d7d9c64977cbfdac0d82e272b117cfbf /lib/Target | |
parent | 03e03b098462c2715598ca96298110b63c57a2d3 (diff) |
Remove the Alpha backend.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143164 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
39 files changed, 0 insertions, 5315 deletions
diff --git a/lib/Target/Alpha/Alpha.h b/lib/Target/Alpha/Alpha.h deleted file mode 100644 index 6ffaf45f4e..0000000000 --- a/lib/Target/Alpha/Alpha.h +++ /dev/null @@ -1,43 +0,0 @@ -//===-- Alpha.h - Top-level interface for Alpha representation --*- 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 the entry points for global functions defined in the LLVM -// Alpha back-end. -// -//===----------------------------------------------------------------------===// - -#ifndef TARGET_ALPHA_H -#define TARGET_ALPHA_H - -#include "MCTargetDesc/AlphaMCTargetDesc.h" -#include "llvm/Target/TargetMachine.h" - -namespace llvm { - namespace Alpha { - // These describe LDAx - - static const int IMM_LOW = -32768; - static const int IMM_HIGH = 32767; - static const int IMM_MULT = 65536; - } - - class AlphaTargetMachine; - class FunctionPass; - class formatted_raw_ostream; - - FunctionPass *createAlphaISelDag(AlphaTargetMachine &TM); - FunctionPass *createAlphaPatternInstructionSelector(TargetMachine &TM); - FunctionPass *createAlphaJITCodeEmitterPass(AlphaTargetMachine &TM, - JITCodeEmitter &JCE); - FunctionPass *createAlphaLLRPPass(AlphaTargetMachine &tm); - FunctionPass *createAlphaBranchSelectionPass(); - -} // end namespace llvm; - -#endif diff --git a/lib/Target/Alpha/Alpha.td b/lib/Target/Alpha/Alpha.td deleted file mode 100644 index ae79c2e4b7..0000000000 --- a/lib/Target/Alpha/Alpha.td +++ /dev/null @@ -1,68 +0,0 @@ -//===- Alpha.td - Describe the Alpha Target Machine --------*- tablegen -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// -//===----------------------------------------------------------------------===// - -// Get the target-independent interfaces which we are implementing... -// -include "llvm/Target/Target.td" - -//Alpha is little endian - -//===----------------------------------------------------------------------===// -// Subtarget Features -//===----------------------------------------------------------------------===// - -def FeatureCIX : SubtargetFeature<"cix", "HasCT", "true", - "Enable CIX extensions">; - -//===----------------------------------------------------------------------===// -// Register File Description -//===----------------------------------------------------------------------===// - -include "AlphaRegisterInfo.td" - -//===----------------------------------------------------------------------===// -// Calling Convention Description -//===----------------------------------------------------------------------===// - -include "AlphaCallingConv.td" - -//===----------------------------------------------------------------------===// -// Schedule Description -//===----------------------------------------------------------------------===// - -include "AlphaSchedule.td" - -//===----------------------------------------------------------------------===// -// Instruction Descriptions -//===----------------------------------------------------------------------===// - -include "AlphaInstrInfo.td" - -def AlphaInstrInfo : InstrInfo; - -//===----------------------------------------------------------------------===// -// Alpha Processor Definitions -//===----------------------------------------------------------------------===// - -def : Processor<"generic", Alpha21264Itineraries, []>; -def : Processor<"ev6" , Alpha21264Itineraries, []>; -def : Processor<"ev67" , Alpha21264Itineraries, [FeatureCIX]>; - -//===----------------------------------------------------------------------===// -// The Alpha Target -//===----------------------------------------------------------------------===// - - -def Alpha : Target { - // Pull in Instruction Info: - let InstructionSet = AlphaInstrInfo; -} diff --git a/lib/Target/Alpha/AlphaAsmPrinter.cpp b/lib/Target/Alpha/AlphaAsmPrinter.cpp deleted file mode 100644 index 5dce06ac86..0000000000 --- a/lib/Target/Alpha/AlphaAsmPrinter.cpp +++ /dev/null @@ -1,166 +0,0 @@ -//===-- AlphaAsmPrinter.cpp - Alpha LLVM assembly writer ------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file contains a printer that converts from our internal representation -// of machine-dependent LLVM code to GAS-format Alpha assembly language. -// -//===----------------------------------------------------------------------===// - -#define DEBUG_TYPE "asm-printer" -#include "Alpha.h" -#include "AlphaInstrInfo.h" -#include "AlphaTargetMachine.h" -#include "llvm/Module.h" -#include "llvm/Type.h" -#include "llvm/Assembly/Writer.h" -#include "llvm/CodeGen/AsmPrinter.h" -#include "llvm/MC/MCStreamer.h" -#include "llvm/MC/MCAsmInfo.h" -#include "llvm/MC/MCSymbol.h" -#include "llvm/Target/Mangler.h" -#include "llvm/Target/TargetLoweringObjectFile.h" -#include "llvm/Target/TargetMachine.h" -#include "llvm/ADT/SmallString.h" -#include "llvm/Support/TargetRegistry.h" -#include "llvm/Support/raw_ostream.h" -using namespace llvm; - -namespace { - struct AlphaAsmPrinter : public AsmPrinter { - /// Unique incrementer for label values for referencing Global values. - /// - - explicit AlphaAsmPrinter(TargetMachine &tm, MCStreamer &Streamer) - : AsmPrinter(tm, Streamer) {} - - virtual const char *getPassName() const { - return "Alpha Assembly Printer"; - } - void printInstruction(const MachineInstr *MI, raw_ostream &O); - void EmitInstruction(const MachineInstr *MI) { - SmallString<128> Str; - raw_svector_ostream OS(Str); - printInstruction(MI, OS); - OutStreamer.EmitRawText(OS.str()); - } - static const char *getRegisterName(unsigned RegNo); - - void printOp(const MachineOperand &MO, raw_ostream &O); - void printOperand(const MachineInstr *MI, int opNum, raw_ostream &O); - virtual void EmitFunctionBodyStart(); - virtual void EmitFunctionBodyEnd(); - void EmitStartOfAsmFile(Module &M); - - bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, - unsigned AsmVariant, const char *ExtraCode, - raw_ostream &O); - bool PrintAsmMemoryOperand(const MachineInstr *MI, - unsigned OpNo, unsigned AsmVariant, - const char *ExtraCode, raw_ostream &O); - }; -} // end of anonymous namespace - -#include "AlphaGenAsmWriter.inc" - -void AlphaAsmPrinter::printOperand(const MachineInstr *MI, int opNum, - raw_ostream &O) { - const MachineOperand &MO = MI->getOperand(opNum); - if (MO.isReg()) { - assert(TargetRegisterInfo::isPhysicalRegister(MO.getReg()) && - "Not physreg??"); - O << getRegisterName(MO.getReg()); - } else if (MO.isImm()) { - O << MO.getImm(); - assert(MO.getImm() < (1 << 30)); - } else { - printOp(MO, O); - } -} - - -void AlphaAsmPrinter::printOp(const MachineOperand &MO, raw_ostream &O) { - switch (MO.getType()) { - case MachineOperand::MO_Register: - O << getRegisterName(MO.getReg()); - return; - - case MachineOperand::MO_Immediate: - assert(0 && "printOp() does not handle immediate values"); - return; - - case MachineOperand::MO_MachineBasicBlock: - O << *MO.getMBB()->getSymbol(); - return; - - case MachineOperand::MO_ConstantPoolIndex: - O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << "_" - << MO.getIndex(); - return; - - case MachineOperand::MO_ExternalSymbol: - O << MO.getSymbolName(); - return; - - case MachineOperand::MO_GlobalAddress: - O << *Mang->getSymbol(MO.getGlobal()); - return; - - case MachineOperand::MO_JumpTableIndex: - O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() - << '_' << MO.getIndex(); - return; - - default: - O << "<unknown operand type: " << MO.getType() << ">"; - return; - } -} - -/// EmitFunctionBodyStart - Targets can override this to emit stuff before -/// the first basic block in the function. -void AlphaAsmPrinter::EmitFunctionBodyStart() { - OutStreamer.EmitRawText("\t.ent " + Twine(CurrentFnSym->getName())); -} - -/// EmitFunctionBodyEnd - Targets can override this to emit stuff after -/// the last basic block in the function. -void AlphaAsmPrinter::EmitFunctionBodyEnd() { - OutStreamer.EmitRawText("\t.end " + Twine(CurrentFnSym->getName())); -} - -void AlphaAsmPrinter::EmitStartOfAsmFile(Module &M) { - OutStreamer.EmitRawText(StringRef("\t.arch ev6")); - OutStreamer.EmitRawText(StringRef("\t.set noat")); -} - -/// PrintAsmOperand - Print out an operand for an inline asm expression. -/// -bool AlphaAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, - unsigned AsmVariant, - const char *ExtraCode, raw_ostream &O) { - printOperand(MI, OpNo, O); - return false; -} - -bool AlphaAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, - unsigned OpNo, unsigned AsmVariant, - const char *ExtraCode, - raw_ostream &O) { - if (ExtraCode && ExtraCode[0]) - return true; // Unknown modifier. - O << "0("; - printOperand(MI, OpNo, O); - O << ")"; - return false; -} - -// Force static initialization. -extern "C" void LLVMInitializeAlphaAsmPrinter() { - RegisterAsmPrinter<AlphaAsmPrinter> X(TheAlphaTarget); -} diff --git a/lib/Target/Alpha/AlphaBranchSelector.cpp b/lib/Target/Alpha/AlphaBranchSelector.cpp deleted file mode 100644 index 3768117095..0000000000 --- a/lib/Target/Alpha/AlphaBranchSelector.cpp +++ /dev/null @@ -1,66 +0,0 @@ -//===-- AlphaBranchSelector.cpp - Convert Pseudo branchs ----------*- C++ -*-=// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// Replace Pseudo COND_BRANCH_* with their appropriate real branch -// Simplified version of the PPC Branch Selector -// -//===----------------------------------------------------------------------===// - -#include "Alpha.h" -#include "AlphaInstrInfo.h" -#include "llvm/CodeGen/MachineFunctionPass.h" -#include "llvm/Target/TargetMachine.h" -#include "llvm/MC/MCAsmInfo.h" -using namespace llvm; - -namespace { - struct AlphaBSel : public MachineFunctionPass { - static char ID; - AlphaBSel() : MachineFunctionPass(ID) {} - - virtual bool runOnMachineFunction(MachineFunction &Fn); - - virtual const char *getPassName() const { - return "Alpha Branch Selection"; - } - }; - char AlphaBSel::ID = 0; -} - -/// createAlphaBranchSelectionPass - returns an instance of the Branch Selection -/// Pass -/// -FunctionPass *llvm::createAlphaBranchSelectionPass() { - return new AlphaBSel(); -} - -bool AlphaBSel::runOnMachineFunction(MachineFunction &Fn) { - - for (MachineFunction::iterator MFI = Fn.begin(), E = Fn.end(); MFI != E; - ++MFI) { - MachineBasicBlock *MBB = MFI; - - for (MachineBasicBlock::iterator MBBI = MBB->begin(), EE = MBB->end(); - MBBI != EE; ++MBBI) { - if (MBBI->getOpcode() == Alpha::COND_BRANCH_I || - MBBI->getOpcode() == Alpha::COND_BRANCH_F) { - - // condbranch operands: - // 0. bc opcode - // 1. reg - // 2. target MBB - const TargetInstrInfo *TII = Fn.getTarget().getInstrInfo(); - MBBI->setDesc(TII->get(MBBI->getOperand(0).getImm())); - } - } - } - - return true; -} - diff --git a/lib/Target/Alpha/AlphaCallingConv.td b/lib/Target/Alpha/AlphaCallingConv.td deleted file mode 100644 index bde8819f46..0000000000 --- a/lib/Target/Alpha/AlphaCallingConv.td +++ /dev/null @@ -1,38 +0,0 @@ -//===- AlphaCallingConv.td - Calling Conventions for Alpha -*- tablegen -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// This describes the calling conventions for Alpha architecture. -//===----------------------------------------------------------------------===// - -//===----------------------------------------------------------------------===// -// Alpha Return Value Calling Convention -//===----------------------------------------------------------------------===// -def RetCC_Alpha : CallingConv<[ - // i64 is returned in register R0 - // R1 is an llvm extension, I don't know what gcc does - CCIfType<[i64], CCAssignToReg<[R0,R1]>>, - - // f32 / f64 are returned in F0/F1 - CCIfType<[f32, f64], CCAssignToReg<[F0, F1]>> -]>; - -//===----------------------------------------------------------------------===// -// Alpha Argument Calling Conventions -//===----------------------------------------------------------------------===// -def CC_Alpha : CallingConv<[ - // The first 6 arguments are passed in registers, whether integer or - // floating-point - CCIfType<[i64], CCAssignToRegWithShadow<[R16, R17, R18, R19, R20, R21], - [F16, F17, F18, F19, F20, F21]>>, - - CCIfType<[f32, f64], CCAssignToRegWithShadow<[F16, F17, F18, F19, F20, F21], - [R16, R17, R18, R19, R20, R21]>>, - - // Stack slots are 8 bytes in size and 8-byte aligned. - CCIfType<[i64, f32, f64], CCAssignToStack<8, 8>> -]>; diff --git a/lib/Target/Alpha/AlphaFrameLowering.cpp b/lib/Target/Alpha/AlphaFrameLowering.cpp deleted file mode 100644 index 690cd1da9c..0000000000 --- a/lib/Target/Alpha/AlphaFrameLowering.cpp +++ /dev/null @@ -1,143 +0,0 @@ -//=====- AlphaFrameLowering.cpp - Alpha Frame Information ------*- 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 the Alpha implementation of TargetFrameLowering class. -// -//===----------------------------------------------------------------------===// - -#include "AlphaFrameLowering.h" -#include "AlphaInstrInfo.h" -#include "AlphaMachineFunctionInfo.h" -#include "llvm/Function.h" -#include "llvm/CodeGen/MachineFrameInfo.h" -#include "llvm/CodeGen/MachineFunction.h" -#include "llvm/CodeGen/MachineInstrBuilder.h" -#include "llvm/ADT/Twine.h" - -using namespace llvm; - -static long getUpper16(long l) { - long y = l / Alpha::IMM_MULT; - if (l % Alpha::IMM_MULT > Alpha::IMM_HIGH) - ++y; - return y; -} - -static long getLower16(long l) { - long h = getUpper16(l); - return l - h * Alpha::IMM_MULT; -} - -// hasFP - Return true if the specified function should have a dedicated frame -// pointer register. This is true if the function has variable sized allocas or -// if frame pointer elimination is disabled. -// -bool AlphaFrameLowering::hasFP(const MachineFunction &MF) const { - const MachineFrameInfo *MFI = MF.getFrameInfo(); - return MFI->hasVarSizedObjects(); -} - -void AlphaFrameLowering::emitPrologue(MachineFunction &MF) const { - MachineBasicBlock &MBB = MF.front(); // Prolog goes in entry BB - MachineBasicBlock::iterator MBBI = MBB.begin(); - MachineFrameInfo *MFI = MF.getFrameInfo(); - const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); - - DebugLoc dl = (MBBI != MBB.end() ? MBBI->getDebugLoc() : DebugLoc()); - bool FP = hasFP(MF); - - // Handle GOP offset - BuildMI(MBB, MBBI, dl, TII.get(Alpha::LDAHg), Alpha::R29) - .addGlobalAddress(MF.getFunction()).addReg(Alpha::R27).addImm(++curgpdist); - BuildMI(MBB, MBBI, dl, TII.get(Alpha::LDAg), Alpha::R29) - .addGlobalAddress(MF.getFunction()).addReg(Alpha::R29).addImm(curgpdist); - - BuildMI(MBB, MBBI, dl, TII.get(Alpha::ALTENT)) - .addGlobalAddress(MF.getFunction()); - - // Get the number of bytes to allocate from the FrameInfo - long NumBytes = MFI->getStackSize(); - - if (FP) - NumBytes += 8; //reserve space for the old FP - - // Do we need to allocate space on the stack? - if (NumBytes == 0) return; - - unsigned Align = getStackAlignment(); - NumBytes = (NumBytes+Align-1)/Align*Align; - - // Update frame info to pretend that this is part of the stack... - MFI->setStackSize(NumBytes); - - // adjust stack pointer: r30 -= numbytes - NumBytes = -NumBytes; - if (NumBytes >= Alpha::IMM_LOW) { - BuildMI(MBB, MBBI, dl, TII.get(Alpha::LDA), Alpha::R30).addImm(NumBytes) - .addReg(Alpha::R30); - } else if (getUpper16(NumBytes) >= Alpha::IMM_LOW) { - BuildMI(MBB, MBBI, dl, TII.get(Alpha::LDAH), Alpha::R30) - .addImm(getUpper16(NumBytes)).addReg(Alpha::R30); - BuildMI(MBB, MBBI, dl, TII.get(Alpha::LDA), Alpha::R30) - .addImm(getLower16(NumBytes)).addReg(Alpha::R30); - } else { - report_fatal_error("Too big a stack frame at " + Twine(NumBytes)); - } - - // Now if we need to, save the old FP and set the new - if (FP) { - BuildMI(MBB, MBBI, dl, TII.get(Alpha::STQ)) - .addReg(Alpha::R15).addImm(0).addReg(Alpha::R30); - // This must be the last instr in the prolog - BuildMI(MBB, MBBI, dl, TII.get(Alpha::BISr), Alpha::R15) - .addReg(Alpha::R30).addReg(Alpha::R30); - } - -} - -void AlphaFrameLowering::emitEpilogue(MachineFunction &MF, - MachineBasicBlock &MBB) const { - const MachineFrameInfo *MFI = MF.getFrameInfo(); - MachineBasicBlock::iterator MBBI = MBB.getLastNonDebugInstr(); - const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); - - assert((MBBI->getOpcode() == Alpha::RETDAG || - MBBI->getOpcode() == Alpha::RETDAGp) - && "Can only insert epilog into returning blocks"); - DebugLoc dl = MBBI->getDebugLoc(); - - bool FP = hasFP(MF); - - // Get the number of bytes allocated from the FrameInfo... - long NumBytes = MFI->getStackSize(); - - //now if we need to, restore the old FP - if (FP) { - //copy the FP into the SP (discards allocas) - BuildMI(MBB, MBBI, dl, TII.get(Alpha::BISr), Alpha::R30).addReg(Alpha::R15) - .addReg(Alpha::R15); - //restore the FP - BuildMI(MBB, MBBI, dl, TII.get(Alpha::LDQ), Alpha::R15) - .addImm(0).addReg(Alpha::R15); - } - - if (NumBytes != 0) { - if (NumBytes <= Alpha::IMM_HIGH) { - BuildMI(MBB, MBBI, dl, TII.get(Alpha::LDA), Alpha::R30).addImm(NumBytes) - .addReg(Alpha::R30); - } else if (getUpper16(NumBytes) <= Alpha::IMM_HIGH) { - BuildMI(MBB, MBBI, dl, TII.get(Alpha::LDAH), Alpha::R30) - .addImm(getUpper16(NumBytes)).addReg(Alpha::R30); - BuildMI(MBB, MBBI, dl, TII.get(Alpha::LDA), Alpha::R30) - .addImm(getLower16(NumBytes)).addReg(Alpha::R30); - } else { - report_fatal_error("Too big a stack frame at " + Twine(NumBytes)); - } - } -} diff --git a/lib/Target/Alpha/AlphaFrameLowering.h b/lib/Target/Alpha/AlphaFrameLowering.h deleted file mode 100644 index ebd9e1bac1..0000000000 --- a/lib/Target/Alpha/AlphaFrameLowering.h +++ /dev/null @@ -1,43 +0,0 @@ -//==-- AlphaFrameLowering.h - Define frame lowering for Alpha --*- C++ -*---==// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// -// -//===----------------------------------------------------------------------===// - -#ifndef ALPHA_FRAMEINFO_H -#define ALPHA_FRAMEINFO_H - -#include "Alpha.h" -#include "AlphaSubtarget.h" -#include "llvm/Target/TargetFrameLowering.h" - -namespace llvm { - class AlphaSubtarget; - -class AlphaFrameLowering : public TargetFrameLowering { - const AlphaSubtarget &STI; - // FIXME: This should end in MachineFunctionInfo, not here! - mutable int curgpdist; -public: - explicit AlphaFrameLowering(const AlphaSubtarget &sti) - : TargetFrameLowering(StackGrowsDown, 16, 0), STI(sti), curgpdist(0) { - } - - /// emitProlog/emitEpilog - These methods insert prolog and epilog code into - /// the function. - void emitPrologue(MachineFunction &MF) const; - void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const; - - bool hasFP(const MachineFunction &MF) const; -}; - -} // End llvm namespace - -#endif diff --git a/lib/Target/Alpha/AlphaISelDAGToDAG.cpp b/lib/Target/Alpha/AlphaISelDAGToDAG.cpp deleted file mode 100644 index f877c65cd6..0000000000 --- a/lib/Target/Alpha/AlphaISelDAGToDAG.cpp +++ /dev/null @@ -1,425 +0,0 @@ -//===-- AlphaISelDAGToDAG.cpp - Alpha pattern matching inst selector ------===// -// -// The LLVM Compiler Infrastructure -// -// This file 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, -// converting from a legalized dag to a Alpha dag. -// -//===----------------------------------------------------------------------===// - -#include "Alpha.h" -#include "AlphaTargetMachine.h" -#include "llvm/CodeGen/MachineInstrBuilder.h" -#include "llvm/CodeGen/MachineFrameInfo.h" -#include "llvm/CodeGen/MachineFunction.h" -#include "llvm/CodeGen/MachineRegisterInfo.h" -#include "llvm/CodeGen/SelectionDAG.h" -#include "llvm/CodeGen/SelectionDAGISel.h" -#include "llvm/Target/TargetOptions.h" -#include "llvm/Constants.h" -#include "llvm/DerivedTypes.h" -#include "llvm/GlobalValue.h" -#include "llvm/Intrinsics.h" -#include "llvm/LLVMContext.h" -#include "llvm/Support/Compiler.h" -#include "llvm/Support/Debug.h" -#include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/MathExtras.h" -#include "llvm/Support/raw_ostream.h" -#include <algorithm> -using namespace llvm; - -namespace { - - //===--------------------------------------------------------------------===// - /// AlphaDAGToDAGISel - Alpha specific code to select Alpha machine - /// instructions for SelectionDAG operations. - class AlphaDAGToDAGISel : public SelectionDAGISel { - static const int64_t IMM_LOW = -32768; - static const int64_t IMM_HIGH = 32767; - static const int64_t IMM_MULT = 65536; - static const int64_t IMM_FULLHIGH = IMM_HIGH + IMM_HIGH * IMM_MULT; - static const int64_t IMM_FULLLOW = IMM_LOW + IMM_LOW * IMM_MULT; - - static int64_t get_ldah16(int64_t x) { - int64_t y = x / IMM_MULT; - if (x % IMM_MULT > IMM_HIGH) - ++y; - return y; - } - - static int64_t get_lda16(int64_t x) { - return x - get_ldah16(x) * IMM_MULT; - } - - /// get_zapImm - Return a zap mask if X is a valid immediate for a zapnot - /// instruction (if not, return 0). Note that this code accepts partial - /// zap masks. For example (and LHS, 1) is a valid zap, as long we know - /// that the bits 1-7 of LHS are already zero. If LHS is non-null, we are - /// in checking mode. If LHS is null, we assume that the mask has already - /// been validated before. - uint64_t get_zapImm(SDValue LHS, uint64_t Constant) const { - uint64_t BitsToCheck = 0; - unsigned Result = 0; - for (unsigned i = 0; i != 8; ++i) { - if (((Constant >> 8*i) & 0xFF) == 0) { - // nothing to do. - } else { - Result |= 1 << i; - if (((Constant >> 8*i) & 0xFF) == 0xFF) { - // If the entire byte is set, zapnot the byte. - } else if (LHS.getNode() == 0) { |