home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / arch / 9127 < prev    next >
Encoding:
Internet Message Format  |  1992-09-01  |  4.5 KB

  1. Path: sparky!uunet!olivea!decwrl!sdd.hp.com!zaphod.mps.ohio-state.edu!darwin.sura.net!convex!news.utdallas.edu!corpgate!bnrgate!bmerh85!bcars64a!bqneh23!schow
  2. From: schow@bqneh23.bnr.ca (Stanley T.H. Chow)
  3. Newsgroups: comp.arch
  4. Subject: Re: trapping speculative ops (LONG)
  5. Message-ID: <1992Sep1.143155.636@bcars64a.bnr.ca>
  6. Date: 1 Sep 92 14:31:55 GMT
  7. References: <1992Aug31.224611.5196@odin.diku.dk>
  8. Sender: news@bcars64a.bnr.ca (Usenet News)
  9. Organization: Bell Northern Research Ltd, Ottawa
  10. Lines: 77
  11.  
  12. In article <1992Aug31.224611.5196@odin.diku.dk> thorinn@diku.dk (Lars Henrik Mathiesen) writes:
  13. >To summarize: trap bits are proposed to enable a compiler to move a
  14. >potentially trapping operation outside of a condition. As a special
  15. >case, this would allow many, if not all, of the same optimizations
  16. >that can be done if a load through a NULL pointer yields zeroes.
  17.  [...]
  18. >The main problem seems to be with subroutine calls. To move an
  19. >instruction across a call, the compiler has to be able to determine
  20. >whether the result will be used. There are a number of cases where
  21. >that is possible; when it is not, we are no worse off than before.
  22.  
  23. How about this for a possible solution: Assuming we have a single
  24. register that contains all the trap-bits, subroutine call should 
  25. just save and restore this trap-bits register along with whichever
  26. subset of the normal registers. (Complication later). This just
  27. means that we treat the trap-bit as part of it's register. We can
  28. save/restore the whole trap register eventhough we don't save all 
  29. the normal registers - this just means that upon return, the 
  30. calling routine better not use any register that it shouldn't, a
  31. normal requirement. I.e., for callee-save registers, this method
  32. is precise in that both content and trap-condition are preserved;
  33. for caller-save registers, the subroutine is allowed to walk over
  34. the register but we choose to preserve the trap condition anyway.
  35.  
  36. There is a nasty complication: are the trap-bits scoreboarded?
  37. If they are, they must be scoreboarded individually (but
  38. possibly the same scoreboard as their registers), then saving the
  39. register will unnecessarily stall the machine and eliminate the
  40. benifits of hosting the loads, etc. We must handle the cases where
  41. a speculative load into a caller-save register is not finished
  42. by the time the subroutine wants to write into that register (I
  43. assume the old operation is discarded and the new write goes into
  44. the pipeline rightaway).
  45.  
  46. Given that we want to scoreboard the trap-bits, I suggest the
  47. simple solution is to have a new instruction that saves a single
  48. register (both content and trap-bit) into two words. (I guess we
  49. will need the converse to restore). This cannot introduce more
  50. stall than the normal scoreboard (especially if we use the same
  51. scoreboard :-) and reqires only trivial changes in compiler. In
  52. this scheme, the trap-bits are distributed and each bit is really
  53. associated with the register it traps, there is no need for a
  54. single trap-bits register. 
  55.  
  56. >If it is certain that a potentially trapped register value will be
  57. >used later, a subroutine can just be allowed to take a trap if it
  58. >tries to save it. (On such a trap, the debugger must unwind the call
  59. >stack to find the source instruction; but the compiler can easily
  60. >construct tables to allow this.) Software convention may define some
  61. >registers as more likely to be the destinations of slow instructions,
  62. >so that a subroutine can avoid stalls by saving them late.
  63.  
  64. If the register is callee-save but speculatively loaded, it really
  65. is not nice to trap.
  66.  
  67. In my scheme, the trap unwinding is exactly the same as before (ok,
  68. the mechanics is the same, but it becomes more important). For each
  69. access, the compiler knows if it is the first in that routine. If it
  70. is the frist read access, then the debugger should go up the call 
  71. stack and look there.
  72.  
  73. >On the other hand, if the value is known to be dead, the calling code
  74. >can move some dummy value into the register; this will reset the trap
  75. >bit, and write-write interlock will prevent outstanding operations
  76. >from setting it later. Again, software convention may define scratch
  77. >registers that do not have to be detoxed (the subroutine promises to
  78. >write them before reading them).
  79.  
  80. Why should we ever do this? Since traps are user-initiated (by accessing
  81. the register) and dead registers should never be accessed. On the other
  82. hand, this is a great debugging aid.
  83.  
  84. --
  85. Stanley Chow            InterNet: schow@BNR.CA
  86. Bell Northern Research  UUCP:     ..!uunet!bnrgate!bqneh3!schow
  87. (613) 763-2831
  88. Me? Represent other people? Don't make them laugh so hard.
  89.