source: icGREP/icgrep-devel/icgrep/IR_Gen/idisa_target.cpp @ 5463

Last change on this file since 5463 was 5458, checked in by lindanl, 2 years ago

Add NVPTX driver.

File size: 1.6 KB
RevLine 
[4984]1/*
2 *  Copyright (c) 2016 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 */
5
[5260]6#include "idisa_target.h"
[5425]7#include <toolchain/toolchain.h>
[5436]8#include <IR_Gen/idisa_sse_builder.h>
[5238]9#include <IR_Gen/idisa_avx_builder.h>
10#include <IR_Gen/idisa_i64_builder.h>
11#include <IR_Gen/idisa_nvptx_builder.h>
[5320]12#include <llvm/IR/Module.h>
[5323]13#include <llvm/ADT/Triple.h>
[4984]14
[5435]15#include <kernels/kernel_builder.h>
16
17using namespace kernel;
18
[5033]19namespace IDISA {
20   
[5446]21KernelBuilder * GetIDISA_Builder(llvm::LLVMContext & C, const std::string & targetTriple) {
[5361]22    unsigned registerWidth = 0;
[5446]23    Triple T(targetTriple);
[5324]24    if (T.isArch64Bit()) {
25        registerWidth = 64;
26    } else if (T.isArch32Bit()) {
27        registerWidth = 32;
28    } else if (T.isArch16Bit()) {
29        registerWidth = 16;
[5323]30    }
[5324]31    const bool hasAVX2 = AVX2_available();
[5217]32    if (LLVM_LIKELY(codegen::BlockSize == 0)) {  // No BlockSize override: use processor SIMD width
33        codegen::BlockSize = hasAVX2 ? 256 : 128;
[4984]34    }
[5217]35    if (codegen::BlockSize >= 256) {
[4984]36        if (hasAVX2) {
[5446]37            return new KernelBuilderImpl<IDISA_AVX2_Builder>(C, registerWidth, codegen::BlockSize, codegen::BlockSize);
[4984]38        }
[5217]39    } else if (codegen::BlockSize == 64) {
[5446]40        return new KernelBuilderImpl<IDISA_I64_Builder>(C, registerWidth, codegen::BlockSize, codegen::BlockSize);
[4984]41    }
[5446]42    return new KernelBuilderImpl<IDISA_SSE2_Builder>(C, registerWidth, codegen::BlockSize, codegen::BlockSize);
[4984]43}
44
[5446]45KernelBuilder * GetIDISA_GPU_Builder(llvm::LLVMContext & C) {
[5458]46    return new KernelBuilderImpl<IDISA_NVPTX20_Builder>(C, 64, 64, 64*64);
[5037]47}
[5151]48
49}
Note: See TracBrowser for help on using the repository browser.