1 / 3

Translator Structure

Translator Structure. Cw Code. AST Structure. Input. Expression BinaryExpression UnaryExpression Declaration Function Statement IfStatement . Lexer Parser. Uses. Intrinsics in Canonical Format. Output: AST. Driver. TranslationUnit. VarDeclaration. FunctionDefinition.

tanginika
Télécharger la présentation

Translator Structure

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Translator Structure Cw Code AST Structure Input ExpressionBinaryExpressionUnaryExpression DeclarationFunction Statement IfStatement .... Lexer Parser Uses Intrinsics in CanonicalFormat Output: AST Driver TranslationUnit VarDeclaration FunctionDefinition Identifier VariableDeclaration Compound-Statement Load IntrinsicsStore IntrinsicsBinaryOperatorIntrinsics.... Intrinsic Emitter .... Cw Translation Pass Other passesin the future Final Output Translated AST

  2. Translation example(Actual Translation) { vector int a[100][8], b[100], c[100][8]; c[:][:] = a[:][:] + b[:]; } { int a[100][8], b[100], c[100][8]; vec4x32 **p_vec_a = (vec4x32**)a; vec4x32 *p_vec_b = (vec4x32*)b; vec4x32 **p_vec_c = (vec4x32**)c; for( cw_i0 = 0; cw_i0 < 100; cw_i0++){ for( cw_i1 = 0; cw_i1 < 8/4; cw_i1++){ vec4x32 vec_a; vec4x32 vec_b; vec_a = vec4x32Load(p_vec_a[cw_i0] + cw_i1); vec_b = vec4x32Load(p_vec_b + cw_i1); vec_a = vec4x32Add(vec_a, vec_b); vec4x32Store(p_vec_c[cw_i0] + cw_i1, vec_a); } } }

  3. Simplified Step { vector int a[100][8], b[100], c[100][8]; c[:][:] = a[:][:] + b[:]; } • Collect vector symbols • a, b, c • Find Assignment Expressions that involve vector symbols • exp = exp • Check LHS if it is Array-Access expression • Identifier[exp][exp] ... • Check types of LHS and RHS to know declared array size, dimension • RHS traverses sub-expressions until it reaches Identifier • Identifier lookup symbol table to find out declared types • Traverse up ancestor ASTNodes until it finds the SymbolTable containing matching symbol • compute dimension and type • Translate RHS • Translate Sub-expressions first • Translation of sub-expression returns vector identifier presented in the innermost for-loop (vec_a, vec_b..) • Translating ArrayAccess • Declare pointer variable for base of array-access • Add pointer specifier as many as num-dimension of declared symbol • Create for-loop nested as many as num-dimensions of declared symbol • Put LOAD intrinsic in the innermost loop • Translate Assignment Expression • put store intrinsics at the end of innermost for-loop body, which is created during RHS translation

More Related