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

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

Add IRBuilder functionality to IDISA_Builder; eliminate separate mBuilder

File size: 1.3 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(getDoubleTy(), mBitBlockWidth/64);
19        Value * a_as_pd = CreateBitCast(a, bitBlock_f64type);
20        Value * mask = 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(getFloatTy(), mBitBlockWidth/32);
26        Value * a_as_ps = CreateBitCast(a, bitBlock_f32type);
27        Value * mask = CreateCall(signmask_f32func, std::vector<Value *>({a_as_ps}));
28        return mask;
29    }
30    Value * mask = CreateICmpSLT(fwCast(fw, a), ConstantAggregateZero::get(fwVectorType(fw)));
31    return CreateBitCast(mask, getIntNTy(mBitBlockWidth/fw));
32}
33   
34}
Note: See TracBrowser for help on using the repository browser.