1 / 6

Pembentukan kode intermediate (contd)

Pembentukan kode intermediate (contd). Skema transisi untuk Statement flow of control S  if E then M 1 S 1 N else M 2 S 2 {backpatch(E.truelist, M 1 .quad); backpatch(E,falselist, M 2 .quad); S.next := merge(S 1 .nextlist, N.nextlist, S 2 .nextlist)}

Download Presentation

Pembentukan kode intermediate (contd)

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. Pembentukan kode intermediate (contd) Skema transisi untuk Statement flow of control • S  if E then M1 S1 N else M2 S2 {backpatch(E.truelist, M1.quad); backpatch(E,falselist, M2.quad); S.next := merge(S1.nextlist, N.nextlist, S2.nextlist)} • N  € {N.nextlist := makelist(nextquad); emit('goto--') • M  € {M.quad := nextquad}

  2. S  if E then M S1 {backpatch(E.truelist, M.quad) S.nextlist := merge(E.falselist, S1.nextlist)} • S  while M1 E do M2 S1 {backpath(S1.nextlist, M1.quad); backpath(E.truelist, M2.quad); S.nextlist := E.falselist; emit('goto' M1.quad)} 6) S  begin L end {S.nextlist := L.nextlist } 7) S  A {S.nextlist := makelist } 8) L  L1 ; M S {backpath(L1.nextlist, M.quad); L.nextlist := S.nextlist } 9) L  S {L.nextlist := S.nextlist }

  3. Pembentukan kode intermediate (contd) A[dim A], misal ‘besarnya’ elemen dari A adalah w, maka elemen ke-I dari A dimulai pada lokasi base + (i-low) x w (*) Low = batas bawah subskrip array Base = address relatif dari storage yang dialokasikan untuk array (base adalah address relatif dari A[Low]).

  4. Pembentukan kode intermediate (contd) Ekspresi (*) dapat diubah menjadi i x w + (base – low x w) c dapat dihitung pada waktu kompilasi dan disimpan dalam tabel simbol Jadi pada runtime A[i], addressnya dapat diperoleh dengan menambahkan i x w dengan c. Untuk dimensi >1 sebagian informasi array(c) juga datap disimpan di tabel simbol

  5. Pembentukan kode intermediate (contd) Array dimensi 2 biasanya disimpan secara row-major(baris demi baris) atau colomn-major(kolom demi kolom). FORTRAN memakai colomn-major, Pascal memakai row-major. Jika dipakai row-major, address dari A[i1,i2] dapat dihitung dengan formula base + ((i1 - low1) x n2 + i2 – low2) x w (+) Dimana low1 adalah batas bawah dari i1 low2 adalah batas bawah dari i2 n2 = high2 – low2 + 1 high2 = batas atas dari i2

  6. Pembentukan kode intermediate (contd) (+) Bisa ditulis sebagai (( i1 x n2) x w + (base-((low1 x n2) +low2) x w) dapat dihitung pada waktu kompilasi Secara umum, untuk dimensi k, A[i1,i2,i3,…,ik] dapat ditentukan address relatifnya sbb : ((…(i1n1 + i2)n3 + i3)…)nk + ik) x w + base(…((low1n2 + low2)n3 + low3)…)nk + lowk) x w Dimana nj = highj – lowj + 1, j

More Related