source: icGREP/icgrep-devel/icgrep/IR_Gen/idisa_i64_builder.cpp @ 5272

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

Changes working towards simplifying accessing stream elements + some modifications to simplify include / forward declarations within the CodeGen? library.

File size: 1.7 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_i64_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#include <llvm/IR/Module.h>
13
14namespace IDISA {
15
16Value * IDISA_I64_Builder::hsimd_packh(unsigned fw, Value * a, Value * b) {
17    Value * a_ = a;
18    Value * b_ = b;
19    for (unsigned w = fw; w < mBitBlockWidth; w *= 2) {
20        Value * himask_odd = simd_and(simd_himask(w), simd_himask(2*w));  // high half of odd fields
21        Value * himask_even = simd_and(simd_himask(w), simd_lomask(2*w));  // high half of even fields
22        b_ = simd_or(simd_and(b_, himask_odd), simd_slli(mBitBlockWidth, simd_and(b_, himask_even), w/2));
23        a_ = simd_or(simd_and(a_, himask_odd), simd_slli(mBitBlockWidth, simd_and(a_, himask_even), w/2));
24    }
25    Value * pk = simd_or(b_, simd_srli(mBitBlockWidth, a_, mBitBlockWidth/2));
26    return pk;
27}
28
29
30Value * IDISA_I64_Builder::hsimd_packl(unsigned fw, Value * a, Value * b) {
31    Value * a_ = a;
32    Value * b_ = b;
33    for (unsigned w = fw; w < mBitBlockWidth; w *= 2) {
34        Value * lomask_odd = simd_and(simd_lomask(w), simd_himask(2*w));  // high half of odd fields
35        Value * lomask_even = simd_and(simd_lomask(w), simd_lomask(2*w));  // high half of even fields
36        b_ = simd_or(simd_and(b_, lomask_even), simd_srli(mBitBlockWidth, simd_and(b_, lomask_odd), w/2));
37        a_ = simd_or(simd_and(a_, lomask_even), simd_srli(mBitBlockWidth, simd_and(a_, lomask_odd), w/2));
38    }
39    Value * pk = simd_or(simd_slli(mBitBlockWidth, b_, mBitBlockWidth/2), a_);
40    return pk;
41}
42
43}
Note: See TracBrowser for help on using the repository browser.