• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     explicit BuiltinLowering(Circuit *circuit): circuit_(circuit), builder_(circuit), acc_(circuit) {}
28     ~BuiltinLowering() = default;
29     void LowerTypedCallBuitin(GateRef gate);
30     GateRef LowerCallTargetCheck(Environment *env, GateRef gate);
31     void LowerTypedSqrt(GateRef gate);
32     GateRef CheckPara(GateRef gate, GateRef funcCheck);
33     void LowerTypedLocaleCompare(GateRef gate);
34 
35 private:
36     void LowerTypedTrigonometric(GateRef gate, BuiltinsStubCSigns::ID id);
37     GateRef TypedTrigonometric(GateRef gate, BuiltinsStubCSigns::ID id);
38     GateRef IntToTaggedIntPtr(GateRef x);
39     void LowerTypedAbs(GateRef gate);
40     GateRef TypedAbs(GateRef gate);
41     GateRef LowerCallRuntime(GateRef glue, GateRef gate, int index, const std::vector<GateRef> &args,
42                              bool useLabel = false);
43     void ReplaceHirWithValue(GateRef hirGate, GateRef value, bool noThrow = false);
44 
45     Circuit *circuit_ {nullptr};
46     CircuitBuilder builder_;
47     GateAccessor acc_;
48 };
49 }  // panda::ecmascript::kungfu
50 #endif  // ECMASCRIPT_COMPILER_BUILTIN_LOWERING_H
51