• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2023 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 #include "operands.h"
16 #include "codegen.h"
17 
18 namespace panda::compiler {
19 
CreateMathTrunc(IntrinsicInst * inst,Reg dst,SRCREGS src)20 void Codegen::CreateMathTrunc([[maybe_unused]] IntrinsicInst *inst, Reg dst, SRCREGS src)
21 {
22     GetEncoder()->EncodeTrunc(dst, src[0]);
23 }
24 
CreateMathRoundAway(IntrinsicInst * inst,Reg dst,SRCREGS src)25 void Codegen::CreateMathRoundAway([[maybe_unused]] IntrinsicInst *inst, Reg dst, SRCREGS src)
26 {
27     GetEncoder()->EncodeRoundAway(dst, src[0]);
28 }
29 
CreateArrayCopyTo(IntrinsicInst * inst,Reg dst,SRCREGS src)30 void Codegen::CreateArrayCopyTo(IntrinsicInst *inst, [[maybe_unused]] Reg dst, SRCREGS src)
31 {
32     auto entrypointId = EntrypointId::INVALID;
33 
34     switch (inst->GetIntrinsicId()) {
35         case RuntimeInterface::IntrinsicId::INTRINSIC_STD_CORE_BOOL_COPY_TO:
36         case RuntimeInterface::IntrinsicId::INTRINSIC_STD_CORE_BYTE_COPY_TO:
37             entrypointId = EntrypointId::ARRAY_COPY_TO_1B;
38             break;
39 
40         case RuntimeInterface::IntrinsicId::INTRINSIC_STD_CORE_CHAR_COPY_TO:
41         case RuntimeInterface::IntrinsicId::INTRINSIC_STD_CORE_SHORT_COPY_TO:
42             entrypointId = EntrypointId::ARRAY_COPY_TO_2B;
43             break;
44 
45         case RuntimeInterface::IntrinsicId::INTRINSIC_STD_CORE_INT_COPY_TO:
46         case RuntimeInterface::IntrinsicId::INTRINSIC_STD_CORE_FLOAT_COPY_TO:
47             entrypointId = EntrypointId::ARRAY_COPY_TO_4B;
48             break;
49 
50         case RuntimeInterface::IntrinsicId::INTRINSIC_STD_CORE_LONG_COPY_TO:
51         case RuntimeInterface::IntrinsicId::INTRINSIC_STD_CORE_DOUBLE_COPY_TO:
52             entrypointId = EntrypointId::ARRAY_COPY_TO_8B;
53             break;
54 
55         default:
56             UNREACHABLE();
57             break;
58     }
59 
60     ASSERT(entrypointId != EntrypointId::COUNT);
61 
62     auto srcObj = src[FIRST_OPERAND];
63     auto dstObj = src[SECOND_OPERAND];
64     auto dstStart = src[THIRD_OPERAND];
65     auto srcStart = src[FOURTH_OPERAND];
66     auto srcEnd = src[FIFTH_OPERAND];
67     CallFastPath(inst, entrypointId, INVALID_REGISTER, RegMask::GetZeroMask(), srcObj, dstObj, dstStart, srcStart,
68                  srcEnd);
69 }
70 }  // namespace panda::compiler
71