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

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

Clean up

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