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

Last change on this file since 5425 was 5425, checked in by nmedfort, 2 years ago

Changes towards separate compilation

File size: 1.4 KB
Line 
1/*
2 *  Copyright (c) 2016 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 */
5
6#include "idisa_target.h"
7#include <toolchain/toolchain.h>
8#include <IR_Gen/idisa_avx_builder.h>
9#include <IR_Gen/idisa_sse_builder.h>
10#include <IR_Gen/idisa_i64_builder.h>
11#include <IR_Gen/idisa_nvptx_builder.h>
12#include <llvm/IR/Module.h>
13#include <llvm/ADT/Triple.h>
14
15namespace IDISA {
16   
17IDISA_Builder * GetIDISA_Builder(llvm::Module * const module) {
18    unsigned registerWidth = 0;
19    Triple T(module->getTargetTriple());
20    if (T.isArch64Bit()) {
21        registerWidth = 64;
22    } else if (T.isArch32Bit()) {
23        registerWidth = 32;
24    } else if (T.isArch16Bit()) {
25        registerWidth = 16;
26    }
27    const bool hasAVX2 = AVX2_available();
28    if (LLVM_LIKELY(codegen::BlockSize == 0)) {  // No BlockSize override: use processor SIMD width
29        codegen::BlockSize = hasAVX2 ? 256 : 128;
30    }
31    if (codegen::BlockSize >= 256) {
32        if (hasAVX2) {
33            return new IDISA_AVX2_Builder(module, registerWidth, codegen::BlockSize);
34        }
35    } else if (codegen::BlockSize == 64) {
36        return new IDISA_I64_Builder(module, registerWidth);
37    }
38    return new IDISA_SSE2_Builder(module, registerWidth, codegen::BlockSize);
39}
40
41IDISA_Builder * GetIDISA_GPU_Builder(llvm::Module * const module) {
42    return new IDISA_NVPTX20_Builder(module, 64);
43}
44
45}
Note: See TracBrowser for help on using the repository browser.