source: icGREP/icgrep-devel/icgrep/IDISA/idisa_target.cpp @ 5001

Last change on this file since 5001 was 5001, checked in by nmedfort, 3 years ago

Symbol table work

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 <llvm/Support/CommandLine.h>
7
8#include <IDISA/idisa_avx_builder.h>
9#include <IDISA/idisa_sse_builder.h>
10#include <IDISA/idisa_i64_builder.h>
11
12// Dynamic processor detection
13#define ISPC_LLVM_VERSION ISPC_LLVM_3_6
14#include <util/ispc.cpp>
15
16static cl::OptionCategory dCodeGenOptions("Code Generation Options", "These options control code generation.");
17
18static cl::opt<int> BlockSize("BlockSize", cl::init(0), cl::desc("specify a block size (defaults to widest SIMD register width in bits)."), cl::cat(dCodeGenOptions));
19
20
21IDISA::IDISA_Builder * GetIDISA_Builder(Module * mod) {
22    bool hasAVX2 = (strncmp(lGetSystemISA(), "avx2", 4) == 0);
23   
24    unsigned theBlockSize = BlockSize;  // from command line
25   
26    if (theBlockSize == 0) {  // No BlockSize override: use processor SIMD width
27        theBlockSize = hasAVX2 ? 256 : 128;
28    }
29    Type * bitBlockType = VectorType::get(IntegerType::get(getGlobalContext(), 64), theBlockSize/64);
30   
31    int blockSize = bitBlockType->isIntegerTy() ? cast<IntegerType>(bitBlockType)->getIntegerBitWidth() : cast<VectorType>(bitBlockType)->getBitWidth();
32    if (blockSize >= 256) {
33        if (hasAVX2) {
34            return new IDISA::IDISA_AVX2_Builder(mod, bitBlockType);
35        }
36        else{
37            return new IDISA::IDISA_SSE2_Builder(mod, bitBlockType);
38        }
39    }
40    else if (blockSize == 64)
41        return new IDISA::IDISA_I64_Builder(mod, bitBlockType);
42    return new IDISA::IDISA_SSE2_Builder(mod, bitBlockType);
43}
44
Note: See TracBrowser for help on using the repository browser.