• 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 
16 #include "cg_occur.h"
17 #include "cg_pre.h"
18 
19 /* The methods associated with the data structures that represent occurrences and work candidates for PRE */
20 namespace maplebe {
21 /* return if this occur dominate occ */
IsDominate(DomAnalysis & dom,CgOccur & occ)22 bool CgOccur::IsDominate(DomAnalysis &dom, CgOccur &occ)
23 {
24     return dom.Dominate(*GetBB(), *occ.GetBB());
25 }
26 
27 /* compute bucket index for the work candidate in workCandHashTable */
ComputeWorkCandHashIndex(const Operand & opnd)28 uint32 PreWorkCandHashTable::ComputeWorkCandHashIndex(const Operand &opnd)
29 {
30     uint32 hashIdx = static_cast<uint32>(reinterpret_cast<uint64>(&opnd) >> k4ByteSize);
31     return hashIdx % workCandHashLength;
32 }
33 
ComputeStmtWorkCandHashIndex(const Insn & insn)34 uint32 PreWorkCandHashTable::ComputeStmtWorkCandHashIndex(const Insn &insn)
35 {
36     uint32 hIdx = (static_cast<uint32>(insn.GetMachineOpcode())) << k3ByteSize;
37     return hIdx % workCandHashLength;
38 }
39 }  // namespace maplebe
40