LLVM API Documentation

HexagonSubtarget.cpp
Go to the documentation of this file.
00001 //===-- HexagonSubtarget.cpp - Hexagon Subtarget Information --------------===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file implements the Hexagon specific subclass of TargetSubtarget.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #include "HexagonSubtarget.h"
00015 #include "Hexagon.h"
00016 #include "HexagonRegisterInfo.h"
00017 #include "llvm/Support/CommandLine.h"
00018 #include "llvm/Support/ErrorHandling.h"
00019 using namespace llvm;
00020 
00021 #define DEBUG_TYPE "hexagon-subtarget"
00022 
00023 #define GET_SUBTARGETINFO_CTOR
00024 #define GET_SUBTARGETINFO_TARGET_DESC
00025 #include "HexagonGenSubtargetInfo.inc"
00026 
00027 static cl::opt<bool>
00028 EnableV3("enable-hexagon-v3", cl::Hidden,
00029          cl::desc("Enable Hexagon V3 instructions."));
00030 
00031 static cl::opt<bool>
00032 EnableMemOps(
00033     "enable-hexagon-memops",
00034     cl::Hidden, cl::ZeroOrMore, cl::ValueDisallowed, cl::init(true),
00035     cl::desc(
00036       "Generate V4 MEMOP in code generation for Hexagon target"));
00037 
00038 static cl::opt<bool>
00039 DisableMemOps(
00040     "disable-hexagon-memops",
00041     cl::Hidden, cl::ZeroOrMore, cl::ValueDisallowed, cl::init(false),
00042     cl::desc(
00043       "Do not generate V4 MEMOP in code generation for Hexagon target"));
00044 
00045 static cl::opt<bool>
00046 EnableIEEERndNear(
00047     "enable-hexagon-ieee-rnd-near",
00048     cl::Hidden, cl::ZeroOrMore, cl::init(false),
00049     cl::desc("Generate non-chopped conversion from fp to int."));
00050 
00051 HexagonSubtarget &
00052 HexagonSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) {
00053   // If the programmer has not specified a Hexagon version, default to -mv4.
00054   if (CPUString.empty())
00055     CPUString = "hexagonv4";
00056 
00057   if (CPUString == "hexagonv2") {
00058     HexagonArchVersion = V2;
00059   } else if (CPUString == "hexagonv3") {
00060     EnableV3 = true;
00061     HexagonArchVersion = V3;
00062   } else if (CPUString == "hexagonv4") {
00063     HexagonArchVersion = V4;
00064   } else if (CPUString == "hexagonv5") {
00065     HexagonArchVersion = V5;
00066   } else {
00067     llvm_unreachable("Unrecognized Hexagon processor version");
00068   }
00069 
00070   ParseSubtargetFeatures(CPUString, FS);
00071   return *this;
00072 }
00073 
00074 HexagonSubtarget::HexagonSubtarget(StringRef TT, StringRef CPU, StringRef FS,
00075                                    const TargetMachine &TM)
00076     : HexagonGenSubtargetInfo(TT, CPU, FS), CPUString(CPU.str()),
00077       DL("e-m:e-p:32:32-i1:32-i64:64-a:0-n32"),
00078       InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM),
00079       TSInfo(DL), FrameLowering() {
00080 
00081   // Initialize scheduling itinerary for the specified CPU.
00082   InstrItins = getInstrItineraryForCPU(CPUString);
00083 
00084   // UseMemOps on by default unless disabled explicitly
00085   if (DisableMemOps)
00086     UseMemOps = false;
00087   else if (EnableMemOps)
00088     UseMemOps = true;
00089   else
00090     UseMemOps = false;
00091 
00092   if (EnableIEEERndNear)
00093     ModeIEEERndNear = true;
00094   else
00095     ModeIEEERndNear = false;
00096 }
00097 
00098 // Pin the vtable to this file.
00099 void HexagonSubtarget::anchor() {}