source: icGREP/icgrep-devel/icgrep/IDISA/idisa_avx_builder.cpp @ 4892

Last change on this file since 4892 was 4892, checked in by cameron, 3 years ago

Move AVX2 specific IDISA function implementations into subclassed builder

File size: 1.5 KB
Line 
1/*
2 *  Copyright (c) 2015 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 *  icgrep is a trademark of International Characters.
5 */
6
7#include "idisa_avx_builder.h"
8#include <llvm/IR/IRBuilder.h>
9#include <llvm/IR/Constants.h>
10#include <llvm/IR/Intrinsics.h>
11#include <llvm/IR/Function.h>
12
13namespace IDISA {
14
15Value * IDISA_AVX2_Builder::hsimd_signmask(unsigned fw, Value * a) {
16    if (fw == 64) {
17        Value * signmask_f64func = Intrinsic::getDeclaration(mMod, Intrinsic::x86_avx_movmsk_pd_256);
18        Type * bitBlock_f64type = VectorType::get(mLLVMBuilder->getDoubleTy(), mBitBlockWidth/64);
19        Value * a_as_pd = mLLVMBuilder->CreateBitCast(a, bitBlock_f64type);
20        Value * mask = mLLVMBuilder->CreateCall(signmask_f64func, std::vector<Value *>({a_as_pd}));
21        return mask;
22    }
23    else if (fw == 32) {
24        Value * signmask_f32func = Intrinsic::getDeclaration(mMod, Intrinsic::x86_avx_movmsk_ps_256);
25        Type * bitBlock_f32type = VectorType::get(mLLVMBuilder->getFloatTy(), mBitBlockWidth/32);
26        Value * a_as_ps = mLLVMBuilder->CreateBitCast(a, bitBlock_f32type);
27        Value * mask = mLLVMBuilder->CreateCall(signmask_f32func, std::vector<Value *>({a_as_ps}));
28        return mask;
29    }
30    Value * mask = mLLVMBuilder->CreateICmpSLT(fwCast(fw, a), ConstantAggregateZero::get(fwVectorType(fw)));
31    return mLLVMBuilder->CreateBitCast(mask, mLLVMBuilder->getIntNTy(mBitBlockWidth/fw));
32}
33   
34}
Note: See TracBrowser for help on using the repository browser.