1 //============================================================================ 2 // Copyright (C) 2014-2020 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 ${filename} 24 // 25 // @brief auto-generated file 26 // 27 // DO NOT EDIT 28 // 29 // Generation Command Line: 30 // ${'\n// '.join(cmdline)} 31 // 32 //============================================================================ 33 // clang-format off 34 #pragma once 35 36 //============================================================================ 37 // Auto-generated ${comment} 38 //============================================================================ 39 %for func in functions: 40 <%argList = ', '.join(func['args'])%>\ 41 ${func['decl']} 42 { 43 %if isX86: 44 %if len(func['args']) != 0: 45 SmallVector<Type*, ${len(func['args'])}> argTypes; 46 %for arg in func['args']: 47 argTypes.push_back(${arg}->getType()); 48 %endfor 49 #if LLVM_VERSION_MAJOR >= 12 50 #define VEC_GET_NUM_ELEMS cast<FixedVectorType>(a->getType())->getNumElements() 51 #elif LLVM_VERSION_MAJOR >= 11 52 #define VEC_GET_NUM_ELEMS cast<VectorType>(a->getType())->getNumElements() 53 #else 54 #define VEC_GET_NUM_ELEMS a->getType()->getVectorNumElements() 55 #endif 56 FunctionType* pFuncTy = FunctionType::get(${ func['returnType'] }, argTypes, false); 57 %else: 58 FunctionType* pFuncTy = FunctionType::get(${ func['returnType'] }, {}, false); 59 %endif: 60 #if LLVM_VERSION_MAJOR >= 9 61 Function* pFunc = cast<Function>(JM()->mpCurrentModule->getOrInsertFunction("meta.intrinsic.${func['name']}", pFuncTy).getCallee()); 62 #else 63 Function* pFunc = cast<Function>(JM()->mpCurrentModule->getOrInsertFunction("meta.intrinsic.${func['name']}", pFuncTy)); 64 #endif 65 return CALL(pFunc, std::initializer_list<Value*>{${argList}}, name); 66 %elif isIntrin: 67 %if len(func['types']) != 0: 68 SmallVector<Type*, ${len(func['types'])}> args; 69 %for arg in func['types']: 70 args.push_back(${arg}->getType()); 71 %endfor 72 Function* pFunc = Intrinsic::getDeclaration(JM()->mpCurrentModule, Intrinsic::${func['intrin']}, args); 73 return CALL(pFunc, std::initializer_list<Value*>{${argList}}, name); 74 %else: 75 Function* pFunc = Intrinsic::getDeclaration(JM()->mpCurrentModule, Intrinsic::${func['intrin']}); 76 return CALL(pFunc, std::initializer_list<Value*>{${argList}}, name); 77 %endif 78 %else: 79 return IRB()->${func['intrin']}(${argList}); 80 %endif 81 } 82 83 % endfor 84 // clang-format on 85