1 /* 2 * Copyright (c) 2022 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 ECMASCRIPT_COMPILER_BUILTIN_LOWERING_H 17 #define ECMASCRIPT_COMPILER_BUILTIN_LOWERING_H 18 19 #include <string> 20 #include "ecmascript/compiler/argument_accessor.h" 21 #include "ecmascript/compiler/builtins/builtins_call_signature.h" 22 #include "ecmascript/compiler/circuit_builder-inl.h" 23 24 namespace panda::ecmascript::kungfu { 25 class BuiltinLowering { 26 public: BuiltinLowering(Circuit * circuit)27 BuiltinLowering(Circuit *circuit): circuit_(circuit), builder_(circuit), 28 acc_(circuit) {} 29 ~BuiltinLowering() = default; 30 void LowerTypedCallBuitin(GateRef gate); 31 GateRef LowerCallTargetCheck(Environment *env, GateRef gate); 32 static BuiltinsStubCSigns::ID GetBuiltinId(std::string idStr); 33 GateRef CheckPara(GateRef gate); 34 private: 35 void LowerTypedTrigonometric(GateRef gate, BuiltinsStubCSigns::ID id); 36 GateRef TypedTrigonometric(GateRef gate, BuiltinsStubCSigns::ID id); 37 GateRef IntToTaggedIntPtr(GateRef x); 38 void LowerTypedSqrt(GateRef gate); 39 GateRef TypedSqrt(GateRef gate); 40 void LowerTypedAbs(GateRef gate); 41 GateRef TypedAbs(GateRef gate); 42 43 Circuit *circuit_ {nullptr}; 44 CircuitBuilder builder_; 45 GateAccessor acc_; 46 }; 47 } // panda::ecmascript::kungfu 48 #endif // ECMASCRIPT_COMPILER_BUILTIN_LOWERING_H 49