Esempio n. 1
0
        int GetSizeOfStructType(FrontendStructType st)
        {
            int pos = 0;

            foreach (var f in st.fields)
            {
                var sizeInBytes = GetSizeOfFrontendType(f.type);
                var alignment   = st.packed ? 1 : GetAlignmentOfFrontendType(f.type);
                pos  = AlignPow2(pos, alignment);
                pos += sizeInBytes;
            }
            var alignmentStruct = st.packed ? 1 : GetAlignmentOfStruct(st);

            pos = AlignPow2(pos, alignmentStruct);
            return(pos);
        }
Esempio n. 2
0
        List <int> GetOffsetsOfStruct(FrontendStructType st)
        {
            // TODO(pragma): is packed
            var result = new List <int>();
            int pos    = 0;

            foreach (var f in st.fields)
            {
                var sizeInBytes = GetSizeOfFrontendType(f.type);
                var alignment   = st.packed ? 1 : GetAlignmentOfFrontendType(f.type);
                pos = AlignPow2(pos, alignment);
                result.Add(pos);
                pos += sizeInBytes;
                Debug.Assert(sizeInBytes > 0);
            }
            return(result);
        }
Esempio n. 3
0
        int GetAlignmentOfStruct(FrontendStructType st)
        {
            var result = st.fields.Select(f => GetAlignmentOfFrontendType(f.type)).Max();

            return(result);
        }
Esempio n. 4
0
 // TODO(pragma): maybe promote this to Frontend
 int GetDISizeOfStruct(FrontendStructType st)
 {
     return(GetSizeOfFrontendType(st));
 }