• 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 #ifndef MAPLE_IR_INCLUDE_PRIM_TYPES_H
17 #define MAPLE_IR_INCLUDE_PRIM_TYPES_H
18 #include "types_def.h"
19 #include "cfg_primitive_types.h"
20 
21 namespace maple {
22 class PrimitiveType {
23 public:
24     // we need implicit conversion from PrimType to PrimitiveType, so there is no explicit keyword here.
PrimitiveType(PrimType type)25     PrimitiveType(PrimType type) : property(GetPrimitiveTypeProperty(type)) {}
26     ~PrimitiveType() = default;
27 
GetType()28     PrimType GetType() const
29     {
30         return property.type;
31     }
32 
IsInteger()33     bool IsInteger() const
34     {
35         return property.IsInteger();
36     }
IsUnsigned()37     bool IsUnsigned() const
38     {
39         return property.IsUnsigned();
40     }
IsAddress()41     bool IsAddress() const
42     {
43         return property.IsAddress();
44     }
IsFloat()45     bool IsFloat() const
46     {
47         return property.IsFloat();
48     }
IsPointer()49     bool IsPointer() const
50     {
51         return property.IsPointer();
52     }
IsSimple()53     bool IsSimple() const
54     {
55         return property.IsSimple();
56     }
57 private:
58     const PrimitiveTypeProperty &property;
59 };
60 }  // namespace maple
61 #endif  // MAPLE_IR_INCLUDE_PRIM_TYPES_H
62