blob: b0bbc272c8ddca272a38d4bac236976c2391307c [file] [log] [blame]
Dragos Sbirlead25de7a2013-06-21 09:20:34 -07001/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18#include "dex_instruction.h"
19
Brian Carlstromfc0e3212013-07-17 14:40:12 -070020#ifndef ART_COMPILER_SEA_IR_INSTRUCTION_TOOLS_H_
21#define ART_COMPILER_SEA_IR_INSTRUCTION_TOOLS_H_
Dragos Sbirlead25de7a2013-06-21 09:20:34 -070022
23// Note: This file has content cannibalized for SEA_IR from the MIR implementation,
24// to avoid having a dependence on MIR.
25namespace sea_ir {
26
27#define DF_NOP 0
28#define DF_UA (1 << kUA)
29#define DF_UB (1 << kUB)
30#define DF_UC (1 << kUC)
31#define DF_A_WIDE (1 << kAWide)
32#define DF_B_WIDE (1 << kBWide)
33#define DF_C_WIDE (1 << kCWide)
34#define DF_DA (1 << kDA)
35#define DF_IS_MOVE (1 << kIsMove)
36#define DF_SETS_CONST (1 << kSetsConst)
37#define DF_FORMAT_35C (1 << kFormat35c)
38#define DF_FORMAT_3RC (1 << kFormat3rc)
39#define DF_NULL_CHK_0 (1 << kNullCheckSrc0)
40#define DF_NULL_CHK_1 (1 << kNullCheckSrc1)
41#define DF_NULL_CHK_2 (1 << kNullCheckSrc2)
42#define DF_NULL_CHK_OUT0 (1 << kNullCheckOut0)
43#define DF_NON_NULL_DST (1 << kDstNonNull)
44#define DF_NON_NULL_RET (1 << kRetNonNull)
45#define DF_NULL_TRANSFER_0 (1 << kNullTransferSrc0)
46#define DF_NULL_TRANSFER_N (1 << kNullTransferSrcN)
47#define DF_RANGE_CHK_1 (1 << kRangeCheckSrc1)
48#define DF_RANGE_CHK_2 (1 << kRangeCheckSrc2)
49#define DF_RANGE_CHK_3 (1 << kRangeCheckSrc3)
50#define DF_FP_A (1 << kFPA)
51#define DF_FP_B (1 << kFPB)
52#define DF_FP_C (1 << kFPC)
53#define DF_CORE_A (1 << kCoreA)
54#define DF_CORE_B (1 << kCoreB)
55#define DF_CORE_C (1 << kCoreC)
56#define DF_REF_A (1 << kRefA)
57#define DF_REF_B (1 << kRefB)
58#define DF_REF_C (1 << kRefC)
59#define DF_UMS (1 << kUsesMethodStar)
60
61#define DF_HAS_USES (DF_UA | DF_UB | DF_UC)
62
63#define DF_HAS_DEFS (DF_DA)
64
65#define DF_HAS_NULL_CHKS (DF_NULL_CHK_0 | \
66 DF_NULL_CHK_1 | \
67 DF_NULL_CHK_2 | \
68 DF_NULL_CHK_OUT0)
69
70#define DF_HAS_RANGE_CHKS (DF_RANGE_CHK_1 | \
71 DF_RANGE_CHK_2 | \
72 DF_RANGE_CHK_3)
73
74#define DF_HAS_NR_CHKS (DF_HAS_NULL_CHKS | \
75 DF_HAS_RANGE_CHKS)
76
77#define DF_A_IS_REG (DF_UA | DF_DA)
78#define DF_B_IS_REG (DF_UB)
79#define DF_C_IS_REG (DF_UC)
80#define DF_IS_GETTER_OR_SETTER (DF_IS_GETTER | DF_IS_SETTER)
81#define DF_USES_FP (DF_FP_A | DF_FP_B | DF_FP_C)
82
83enum DataFlowAttributePos {
84 kUA = 0,
85 kUB,
86 kUC,
87 kAWide,
88 kBWide,
89 kCWide,
90 kDA,
91 kIsMove,
92 kSetsConst,
93 kFormat35c,
94 kFormat3rc,
95 kNullCheckSrc0, // Null check of uses[0].
96 kNullCheckSrc1, // Null check of uses[1].
97 kNullCheckSrc2, // Null check of uses[2].
98 kNullCheckOut0, // Null check out outgoing arg0.
99 kDstNonNull, // May assume dst is non-null.
100 kRetNonNull, // May assume retval is non-null.
101 kNullTransferSrc0, // Object copy src[0] -> dst.
102 kNullTransferSrcN, // Phi null check state transfer.
103 kRangeCheckSrc1, // Range check of uses[1].
104 kRangeCheckSrc2, // Range check of uses[2].
105 kRangeCheckSrc3, // Range check of uses[3].
106 kFPA,
107 kFPB,
108 kFPC,
109 kCoreA,
110 kCoreB,
111 kCoreC,
112 kRefA,
113 kRefB,
114 kRefC,
115 kUsesMethodStar, // Implicit use of Method*.
116};
117
118class InstructionTools {
119 public:
120 static bool IsDefinition(const art::Instruction* instruction);
121 static const int instruction_attributes_[];
122};
123} // end namespace sea_ir
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700124#endif // ART_COMPILER_SEA_IR_INSTRUCTION_TOOLS_H_