program_mult.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Aplica o back-end do juninho
  2. @target : mips
  3. // Especifica o tipo de metodo empregado para salvar o resultado da compilação
  4. //@export : MultCoreJun
  5. @export : simulation
  6. package main;
  7. const (
  8. LIN = 2
  9. COL = 2
  10. )
  11. var (
  12. matrizA [LIN][COL]int32
  13. matrizB [LIN][COL]int32
  14. matrizR [LIN][COL]int32
  15. )
  16. func preenche(){
  17. var k = 1
  18. for i := 0; i < LIN ; i++ {
  19. for j := 0; j < COL ; j++ {
  20. matrizA[i][j] = k
  21. matrizB[i][j] = k
  22. k++
  23. }
  24. }
  25. }
  26. func multiplica() {
  27. var aux = 0
  28. for i := 0; i < LIN; i++ {
  29. for j := 0; j < COL; j++ {
  30. for k := 0; k < LIN; k++ {
  31. aux = aux + (matrizA[i][k] * matrizB[k][j])
  32. }
  33. matrizR[i][j] = aux
  34. aux = 0
  35. }
  36. }
  37. }
  38. func main() {
  39. preenche()
  40. multiplica()
  41. }
  42. /**
  43. load (int32) i T< load >
  44. 10: 9: _T4 := i --Copy value of index T< copy >
  45. 11: 10: _T5 := _T4 << 1 T< assign >
  46. 12: 11: load (int32) j T< load >
  47. 13: 12: _T7 := j --Copy value of index T< copy >
  48. 14: 13: _T5 := _T5 + _T7 --colls shift T< assign >
  49. 15: 14: _T11 := _T5 << 4 T< assign >
  50. 16: 15: load (int32) aux T< load >
  51. 17: 16: matrizA[_T11] := aux T< indexed_assign >
  52. [2][2]
  53. i j t4 t5 t7 t11
  54. 9 1 1 1
  55. 10 2
  56. 11
  57. 12 1
  58. 13 3
  59. 14
  60. 15
  61. 16
  62. 17
  63. sll t6,t4,4 .14 -- _T11 = _T5 << 4
  64. 60: 2413101056 lw s5,fp,0 .15 -- load content from _V1 in s5
  65. 64: 0000000000 sll zero,zero,0 .15 -- Nop
  66. 68: 0059666465 addu t6,gp,t6 .16
  67. 6c: 2916417536 sw s5,t6,0 .16 -- store content of t6 in _G13[_T11]
  68. t6 tem o deslocamento em bytes
  69. */