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

Last change on this file since 5795 was 5464, checked in by nmedfort, 22 months ago

Restructuring work for the Driver classes. Start of work to eliminate the memory leaks with the ExecutionEngine?. Replaced custom AlignedMalloc? with backend call to std::aligned_malloc. Salvaged some work on DistributionPass? for reevaluation.

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
9using namespace llvm;
10
11namespace IDISA {
12   
13std::string IDISA_I64_Builder::getBuilderUniqueName() { return mBitBlockWidth != 64 ? "C" + std::to_string(mBitBlockWidth) : "C";}
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    return simd_or(b_, simd_srli(mBitBlockWidth, a_, mBitBlockWidth/2));
25}
26
27Value * IDISA_I64_Builder::hsimd_packl(unsigned fw, Value * a, Value * b) {
28    Value * a_ = a;
29    Value * b_ = b;
30    for (unsigned w = fw; w < mBitBlockWidth; w *= 2) {
31        Value * lomask_odd = simd_and(simd_lomask(w), simd_himask(2*w));  // high half of odd fields
32        Value * lomask_even = simd_and(simd_lomask(w), simd_lomask(2*w));  // high half of even fields
33        b_ = simd_or(simd_and(b_, lomask_even), simd_srli(mBitBlockWidth, simd_and(b_, lomask_odd), w/2));
34        a_ = simd_or(simd_and(a_, lomask_even), simd_srli(mBitBlockWidth, simd_and(a_, lomask_odd), w/2));
35    }
36    return simd_or(simd_slli(mBitBlockWidth, b_, mBitBlockWidth/2), a_);
37}
38
39}
Note: See TracBrowser for help on using the repository browser.