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

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

Continued work on parenthesis matching; addition of Pablo ScanTo? and AdvanceThenScanTo/Thru? statements. Bug fix for Pablo Compiler for escaping variables.

File size: 1.6 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.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 * mod) {
18    if (LLVM_UNLIKELY(mod == nullptr)) {
19        report_fatal_error("GetIDISA_Builder: module cannot be null");
20    }
21    if (LLVM_LIKELY(mod->getTargetTriple().empty())) {
22        mod->setTargetTriple(llvm::sys::getProcessTriple());
23    }
24    Triple T(mod->getTargetTriple());
25    unsigned registerWidth = 32;
26    if (T.isArch64Bit()) {
27        registerWidth = 64;
28    } else if (T.isArch32Bit()) {
29        registerWidth = 32;
30    } else if (T.isArch16Bit()) {
31        registerWidth = 16;
32    }
33    const bool hasAVX2 = AVX2_available();
34    if (LLVM_LIKELY(codegen::BlockSize == 0)) {  // No BlockSize override: use processor SIMD width
35        codegen::BlockSize = hasAVX2 ? 256 : 128;
36    }
37    if (codegen::BlockSize >= 256) {
38        if (hasAVX2) {
39            return new IDISA_AVX2_Builder(mod, registerWidth, codegen::BlockSize);
40        }
41    } else if (codegen::BlockSize == 64) {
42        return new IDISA_I64_Builder(mod, registerWidth);
43    }
44    return new IDISA_SSE2_Builder(mod, registerWidth, codegen::BlockSize);
45}
46
47IDISA_Builder * GetIDISA_GPU_Builder(llvm::Module * mod) {
48    return new IDISA_NVPTX20_Builder(mod, 64);
49}
50
51}
Note: See TracBrowser for help on using the repository browser.