Exemple #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);
        }
Exemple #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);
        }
Exemple #3
0
        int GetAlignmentOfStruct(FrontendStructType st)
        {
            var result = st.fields.Select(f => GetAlignmentOfFrontendType(f.type)).Max();

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