From f6bb60605a7fc1ce7e4ad5171222e80f7ec86f4c Mon Sep 17 00:00:00 2001 From: linma Date: Tue, 27 Apr 2021 13:56:34 -0700 Subject: [PATCH] merge ptr size (POINTER_SIZE and POINTER_P2SIZE) from icubator --- src/mapleall/maple_ir/include/mir_type.h | 5 +++++ src/mapleall/maple_ir/src/mir_type.cpp | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/mapleall/maple_ir/include/mir_type.h b/src/mapleall/maple_ir/include/mir_type.h index 13c000477a..dbbb85d862 100644 --- a/src/mapleall/maple_ir/include/mir_type.h +++ b/src/mapleall/maple_ir/include/mir_type.h @@ -24,6 +24,9 @@ #include "mempool_allocator.h" #endif // MIR_FEATURE_FULL +#define POINTER_SIZE 8 +#define POINTER_P2SIZE 3 + namespace maple { constexpr int kTypeHashLength = 12289; // hash length for mirtype, ref: planetmath.org/goodhashtableprimes @@ -588,6 +591,8 @@ class MIRPtrType : public MIRType { bool IsPointedTypeVolatile(int fieldID) const; void Dump(int indent, bool dontUseName = false) const override; + size_t GetSize() const override { return POINTER_SIZE; } + uint32 GetAlign() const override { return POINTER_SIZE; } TyIdxFieldAttrPair GetPointedTyIdxFldAttrPairWithFieldID(FieldID fldId) const; TyIdx GetPointedTyIdxWithFieldID(FieldID fieldID) const; size_t GetHashIndex() const override { diff --git a/src/mapleall/maple_ir/src/mir_type.cpp b/src/mapleall/maple_ir/src/mir_type.cpp index c3163794d9..4b28e02631 100644 --- a/src/mapleall/maple_ir/src/mir_type.cpp +++ b/src/mapleall/maple_ir/src/mir_type.cpp @@ -173,6 +173,9 @@ uint32 GetPrimTypeSize(PrimType primType) { case PTY_void: case PTY_agg: return 0; + case PTY_ptr: + case PTY_ref: + return POINTER_SIZE; case PTY_u1: case PTY_i8: case PTY_u8: @@ -217,6 +220,9 @@ uint32 GetPrimTypeSize(PrimType primType) { // answer is n if size in byte is (1<