MSP430-Profiling-Capability.html 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- This file documents the GNU Assembler "as".
  4. Copyright (C) 1991-2017 Free Software Foundation, Inc.
  5. Permission is granted to copy, distribute and/or modify this document
  6. under the terms of the GNU Free Documentation License, Version 1.3
  7. or any later version published by the Free Software Foundation;
  8. with no Invariant Sections, with no Front-Cover Texts, and with no
  9. Back-Cover Texts. A copy of the license is included in the
  10. section entitled "GNU Free Documentation License".
  11. -->
  12. <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
  13. <head>
  14. <title>Using as: MSP430 Profiling Capability</title>
  15. <meta name="description" content="Using as: MSP430 Profiling Capability">
  16. <meta name="keywords" content="Using as: MSP430 Profiling Capability">
  17. <meta name="resource-type" content="document">
  18. <meta name="distribution" content="global">
  19. <meta name="Generator" content="makeinfo">
  20. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  21. <link href="index.html#Top" rel="start" title="Top">
  22. <link href="AS-Index.html#AS-Index" rel="index" title="AS Index">
  23. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  24. <link href="MSP430_002dDependent.html#MSP430_002dDependent" rel="up" title="MSP430-Dependent">
  25. <link href="NDS32_002dDependent.html#NDS32_002dDependent" rel="next" title="NDS32-Dependent">
  26. <link href="MSP430-Opcodes.html#MSP430-Opcodes" rel="prev" title="MSP430 Opcodes">
  27. <style type="text/css">
  28. <!--
  29. a.summary-letter {text-decoration: none}
  30. blockquote.smallquotation {font-size: smaller}
  31. div.display {margin-left: 3.2em}
  32. div.example {margin-left: 3.2em}
  33. div.indentedblock {margin-left: 3.2em}
  34. div.lisp {margin-left: 3.2em}
  35. div.smalldisplay {margin-left: 3.2em}
  36. div.smallexample {margin-left: 3.2em}
  37. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  38. div.smalllisp {margin-left: 3.2em}
  39. kbd {font-style:oblique}
  40. pre.display {font-family: inherit}
  41. pre.format {font-family: inherit}
  42. pre.menu-comment {font-family: serif}
  43. pre.menu-preformatted {font-family: serif}
  44. pre.smalldisplay {font-family: inherit; font-size: smaller}
  45. pre.smallexample {font-size: smaller}
  46. pre.smallformat {font-family: inherit; font-size: smaller}
  47. pre.smalllisp {font-size: smaller}
  48. span.nocodebreak {white-space:nowrap}
  49. span.nolinebreak {white-space:nowrap}
  50. span.roman {font-family:serif; font-weight:normal}
  51. span.sansserif {font-family:sans-serif; font-weight:normal}
  52. ul.no-bullet {list-style: none}
  53. -->
  54. </style>
  55. </head>
  56. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  57. <a name="MSP430-Profiling-Capability"></a>
  58. <div class="header">
  59. <p>
  60. Previous: <a href="MSP430-Opcodes.html#MSP430-Opcodes" accesskey="p" rel="prev">MSP430 Opcodes</a>, Up: <a href="MSP430_002dDependent.html#MSP430_002dDependent" accesskey="u" rel="up">MSP430-Dependent</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="AS-Index.html#AS-Index" title="Index" rel="index">Index</a>]</p>
  61. </div>
  62. <hr>
  63. <a name="Profiling-Capability"></a>
  64. <h4 class="subsection">9.29.6 Profiling Capability</h4>
  65. <a name="index-MSP-430-profiling-capability"></a>
  66. <a name="index-profiling-capability-for-MSP-430"></a>
  67. <p>It is a performance hit to use gcc&rsquo;s profiling approach for this tiny target.
  68. Even more &ndash; jtag hardware facility does not perform any profiling functions.
  69. However we&rsquo;ve got gdb&rsquo;s built-in simulator where we can do anything.
  70. </p>
  71. <p>We define new section &lsquo;<samp>.profiler</samp>&rsquo; which holds all profiling information.
  72. We define new pseudo operation &lsquo;<samp>.profiler</samp>&rsquo; which will instruct assembler to
  73. add new profile entry to the object file. Profile should take place at the
  74. present address.
  75. </p>
  76. <p>Pseudo operation format:
  77. </p>
  78. <p>&lsquo;<samp>.profiler flags,function_to_profile [, cycle_corrector, extra]</samp>&rsquo;
  79. </p>
  80. <p>where:
  81. </p>
  82. <dl compact="compact">
  83. <dd>
  84. <dl compact="compact">
  85. <dd>
  86. <p>&lsquo;<samp>flags</samp>&rsquo; is a combination of the following characters:
  87. </p>
  88. </dd>
  89. <dt><code>s</code></dt>
  90. <dd><p>function entry
  91. </p></dd>
  92. <dt><code>x</code></dt>
  93. <dd><p>function exit
  94. </p></dd>
  95. <dt><code>i</code></dt>
  96. <dd><p>function is in init section
  97. </p></dd>
  98. <dt><code>f</code></dt>
  99. <dd><p>function is in fini section
  100. </p></dd>
  101. <dt><code>l</code></dt>
  102. <dd><p>library call
  103. </p></dd>
  104. <dt><code>c</code></dt>
  105. <dd><p>libc standard call
  106. </p></dd>
  107. <dt><code>d</code></dt>
  108. <dd><p>stack value demand
  109. </p></dd>
  110. <dt><code>I</code></dt>
  111. <dd><p>interrupt service routine
  112. </p></dd>
  113. <dt><code>P</code></dt>
  114. <dd><p>prologue start
  115. </p></dd>
  116. <dt><code>p</code></dt>
  117. <dd><p>prologue end
  118. </p></dd>
  119. <dt><code>E</code></dt>
  120. <dd><p>epilogue start
  121. </p></dd>
  122. <dt><code>e</code></dt>
  123. <dd><p>epilogue end
  124. </p></dd>
  125. <dt><code>j</code></dt>
  126. <dd><p>long jump / sjlj unwind
  127. </p></dd>
  128. <dt><code>a</code></dt>
  129. <dd><p>an arbitrary code fragment
  130. </p></dd>
  131. <dt><code>t</code></dt>
  132. <dd><p>extra parameter saved (a constant value like frame size)
  133. </p></dd>
  134. </dl>
  135. </dd>
  136. <dt><code>function_to_profile</code></dt>
  137. <dd><p>a function address
  138. </p></dd>
  139. <dt><code>cycle_corrector</code></dt>
  140. <dd><p>a value which should be added to the cycle counter, zero if omitted.
  141. </p></dd>
  142. <dt><code>extra</code></dt>
  143. <dd><p>any extra parameter, zero if omitted.
  144. </p>
  145. </dd>
  146. </dl>
  147. <p>For example:
  148. </p><div class="smallexample">
  149. <pre class="smallexample">.global fxx
  150. .type fxx,@function
  151. fxx:
  152. .LFrameOffset_fxx=0x08
  153. .profiler &quot;scdP&quot;, fxx ; function entry.
  154. ; we also demand stack value to be saved
  155. push r11
  156. push r10
  157. push r9
  158. push r8
  159. .profiler &quot;cdpt&quot;,fxx,0, .LFrameOffset_fxx ; check stack value at this point
  160. ; (this is a prologue end)
  161. ; note, that spare var filled with
  162. ; the farme size
  163. mov r15,r8
  164. ...
  165. .profiler cdE,fxx ; check stack
  166. pop r8
  167. pop r9
  168. pop r10
  169. pop r11
  170. .profiler xcde,fxx,3 ; exit adds 3 to the cycle counter
  171. ret ; cause 'ret' insn takes 3 cycles
  172. </pre></div>
  173. <hr>
  174. <div class="header">
  175. <p>
  176. Previous: <a href="MSP430-Opcodes.html#MSP430-Opcodes" accesskey="p" rel="prev">MSP430 Opcodes</a>, Up: <a href="MSP430_002dDependent.html#MSP430_002dDependent" accesskey="u" rel="up">MSP430-Dependent</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="AS-Index.html#AS-Index" title="Index" rel="index">Index</a>]</p>
  177. </div>
  178. </body>
  179. </html>