swr/rast: Widen fetch shader to SIMD16
[mesa.git] / src / gallium / drivers / swr / rasterizer / jitter / builder.cpp
1 /****************************************************************************
2 * Copyright (C) 2014-2015 Intel Corporation. All Rights Reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 * @file builder.h
24 *
25 * @brief Includes all the builder related functionality
26 *
27 * Notes:
28 *
29 ******************************************************************************/
30
31 #include "builder.h"
32
33 namespace SwrJit
34 {
35 using namespace llvm;
36
37 //////////////////////////////////////////////////////////////////////////
38 /// @brief Contructor for Builder.
39 /// @param pJitMgr - JitManager which contains modules, function passes, etc.
40 Builder::Builder(JitManager *pJitMgr)
41 : mpJitMgr(pJitMgr)
42 {
43 mVWidth = pJitMgr->mVWidth;
44 #if USE_SIMD16_BUILDER
45 mVWidth2 = pJitMgr->mVWidth * 2;
46 #endif
47
48 mpIRBuilder = &pJitMgr->mBuilder;
49
50 mVoidTy = Type::getVoidTy(pJitMgr->mContext);
51 mFP16Ty = Type::getHalfTy(pJitMgr->mContext);
52 mFP32Ty = Type::getFloatTy(pJitMgr->mContext);
53 mFP32PtrTy = PointerType::get(mFP32Ty, 0);
54 mDoubleTy = Type::getDoubleTy(pJitMgr->mContext);
55 mInt1Ty = Type::getInt1Ty(pJitMgr->mContext);
56 mInt8Ty = Type::getInt8Ty(pJitMgr->mContext);
57 mInt16Ty = Type::getInt16Ty(pJitMgr->mContext);
58 mInt32Ty = Type::getInt32Ty(pJitMgr->mContext);
59 mInt8PtrTy = PointerType::get(mInt8Ty, 0);
60 mInt16PtrTy = PointerType::get(mInt16Ty, 0);
61 mInt32PtrTy = PointerType::get(mInt32Ty, 0);
62 mInt64Ty = Type::getInt64Ty(pJitMgr->mContext);
63 mSimdInt1Ty = VectorType::get(mInt1Ty, mVWidth);
64 mSimdInt16Ty = VectorType::get(mInt16Ty, mVWidth);
65 mSimdInt32Ty = VectorType::get(mInt32Ty, mVWidth);
66 mSimdInt64Ty = VectorType::get(mInt64Ty, mVWidth);
67 mSimdFP16Ty = VectorType::get(mFP16Ty, mVWidth);
68 mSimdFP32Ty = VectorType::get(mFP32Ty, mVWidth);
69 mSimdVectorTy = ArrayType::get(mSimdFP32Ty, 4);
70 mSimdVectorTRTy = ArrayType::get(mSimdFP32Ty, 5);
71 #if USE_SIMD16_BUILDER
72 mSimd2Int1Ty = VectorType::get(mInt1Ty, mVWidth2);
73 mSimd2Int16Ty = VectorType::get(mInt16Ty, mVWidth2);
74 mSimd2Int32Ty = VectorType::get(mInt32Ty, mVWidth2);
75 mSimd2Int64Ty = VectorType::get(mInt64Ty, mVWidth2);
76 mSimd2FP16Ty = VectorType::get(mFP16Ty, mVWidth2);
77 mSimd2FP32Ty = VectorType::get(mFP32Ty, mVWidth2);
78 mSimd2VectorTy = ArrayType::get(mSimd2FP32Ty, 4);
79 mSimd2VectorTRTy = ArrayType::get(mSimd2FP32Ty, 5);
80 #endif
81
82 if (sizeof(uint32_t*) == 4)
83 {
84 mIntPtrTy = mInt32Ty;
85 mSimdIntPtrTy = mSimdInt32Ty;
86 #if USE_SIMD16_BUILDER
87 mSimd2IntPtrTy = mSimd2Int32Ty;
88 #endif
89 }
90 else
91 {
92 SWR_ASSERT(sizeof(uint32_t*) == 8);
93
94 mIntPtrTy = mInt64Ty;
95 mSimdIntPtrTy = mSimdInt64Ty;
96 #if USE_SIMD16_BUILDER
97 mSimd2IntPtrTy = mSimd2Int64Ty;
98 #endif
99 }
100 }
101 }