1 /* 2 * Copyright (c) 2021-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef CONST_FOLDING_H 17 #define CONST_FOLDING_H 18 19 namespace ark::compiler { 20 21 bool ConstFoldingCast(Inst *inst); 22 bool ConstFoldingNeg(Inst *inst); 23 bool ConstFoldingAbs(Inst *inst); 24 bool ConstFoldingNot(Inst *inst); 25 bool ConstFoldingAdd(Inst *inst); 26 bool ConstFoldingSub(Inst *inst); 27 bool ConstFoldingMul(Inst *inst); 28 bool ConstFoldingBinaryMathWithNan(Inst *inst); 29 bool ConstFoldingDiv(Inst *inst); 30 bool ConstFoldingDivWithNan(Inst *inst); 31 bool ConstFoldingMin(Inst *inst); 32 bool ConstFoldingMax(Inst *inst); 33 bool ConstFoldingMod(Inst *inst); 34 bool ConstFoldingShl(Inst *inst); 35 bool ConstFoldingShr(Inst *inst); 36 bool ConstFoldingAShr(Inst *inst); 37 bool ConstFoldingAnd(Inst *inst); 38 bool ConstFoldingOr(Inst *inst); 39 bool ConstFoldingXor(Inst *inst); 40 bool ConstFoldingCmp(Inst *inst); 41 bool ConstFoldingCompare(Inst *inst); 42 bool ConstFoldingSqrt(Inst *inst); 43 bool ConstFoldingLoadStatic(Inst *inst); 44 45 // NB: casting may be required to create constants of the desired array type for creating LiteralArrays (in Bytecode 46 // Optimizer ConstArrayResolver pass) If a constant is used to initialize an array (is_literal_data == true), it must be 47 // able to be cast to the appropriate types 48 PANDA_PUBLIC_API ConstantInst *ConstFoldingCastConst(Inst *inst, Inst *input, bool isLiteralData = false); 49 50 ConstantInst *ConstFoldingCreateIntConst(Inst *inst, uint64_t value, bool isLiteralData = false); 51 } // namespace ark::compiler 52 #endif // CONST_FOLDING_H 53