Ignore:
Timestamp:
Feb 26, 2017, 4:30:51 PM (2 years ago)
Author:
nmedfort
Message:

First attempt at inlining all DoBlock? and FinalBlock? functions by using indirect jumps. Disabled for NVPTX until Linda can check whether they're supported by the LLVM NVPTX library.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/toolchain.cpp

    r5347 r5350  
    1919#include <llvm/Target/TargetMachine.h>             // for TargetMachine, Tar...
    2020#include <llvm/Target/TargetOptions.h>             // for TargetOptions
     21#include <llvm/Transforms/Scalar.h>
     22#include <llvm/Transforms/Utils/Local.h>
     23#ifndef NDEBUG
     24#include <llvm/IR/Verifier.h>
     25#endif
    2126#include <object_cache.h>
    2227namespace llvm { class Module; }
     
    110115
    111116    std::error_code error;
    112     llvm::raw_fd_ostream out(IRFilename, error, sys::fs::OpenFlags::F_None);
     117    raw_fd_ostream out(IRFilename, error, sys::fs::OpenFlags::F_None);
    113118    m->print(out, nullptr);
    114119
     
    122127
    123128void setAllFeatures(EngineBuilder &builder) {
    124     llvm::StringMap<bool> HostCPUFeatures;
    125     if (llvm::sys::getHostCPUFeatures(HostCPUFeatures)) {
     129    StringMap<bool> HostCPUFeatures;
     130    if (sys::getHostCPUFeatures(HostCPUFeatures)) {
    126131        std::vector<std::string> attrs;
    127132        for (auto &flag : HostCPUFeatures) {
     
    134139
    135140bool AVX2_available() {
    136     llvm::StringMap<bool> HostCPUFeatures;
    137     if (llvm::sys::getHostCPUFeatures(HostCPUFeatures)) {
     141    StringMap<bool> HostCPUFeatures;
     142    if (sys::getHostCPUFeatures(HostCPUFeatures)) {
    138143        auto f = HostCPUFeatures.find("avx2");
    139144        return ((f != HostCPUFeatures.end()) && f->second);
     
    143148
    144149#ifndef USE_LLVM_3_6
    145 void WriteAssembly (llvm::TargetMachine *TM, Module * m) {
    146     llvm::legacy::PassManager PM;
    147 
    148     llvm::SmallString<128> Str;
    149     llvm::raw_svector_ostream dest(Str);
    150 
    151     if (TM->addPassesToEmitFile(PM, dest, llvm::TargetMachine::CGFT_AssemblyFile ) ) {
     150void WriteAssembly (TargetMachine *TM, Module * m) {
     151    legacy::PassManager PM;
     152
     153    SmallString<128> Str;
     154    raw_svector_ostream dest(Str);
     155
     156    if (TM->addPassesToEmitFile(PM, dest, TargetMachine::CGFT_AssemblyFile ) ) {
    152157        throw std::runtime_error("LLVM error: addPassesToEmitFile failed.");
    153158    }
     
    158163    } else {
    159164        std::error_code error;
    160         llvm::raw_fd_ostream out(codegen::ASMOutputFilename, error, sys::fs::OpenFlags::F_None);
     165        raw_fd_ostream out(codegen::ASMOutputFilename, error, sys::fs::OpenFlags::F_None);
    161166        out << Str;
    162167    }
     
    165170
    166171ExecutionEngine * JIT_to_ExecutionEngine (Module * m) {
     172
     173    // Use the pass manager to optimize the function.
     174    legacy::PassManager PM;
     175    #ifndef NDEBUG
     176    PM.add(createVerifierPass());
     177    #endif
     178    PM.add(createReassociatePass());             //Reassociate expressions.
     179    PM.add(createGVNPass());                     //Eliminate common subexpressions.
     180    PM.add(createInstructionCombiningPass());    //Simple peephole optimizations and bit-twiddling.
     181    PM.add(createCFGSimplificationPass());
     182    PM.run(*m);
    167183
    168184    InitializeNativeTarget();
     
    200216        } else {
    201217            std::error_code error;
    202             llvm::raw_fd_ostream out(codegen::IROutputFilename, error, sys::fs::OpenFlags::F_None);
     218            raw_fd_ostream out(codegen::IROutputFilename, error, sys::fs::OpenFlags::F_None);
    203219            m->print(out, nullptr);
    204220        }
Note: See TracChangeset for help on using the changeset viewer.