gimple-pretty-print.c.orig 83 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054
  1. /* Pretty formatting of GIMPLE statements and expressions.
  2. Copyright (C) 2001-2020 Free Software Foundation, Inc.
  3. Contributed by Aldy Hernandez <aldyh@redhat.com> and
  4. Diego Novillo <dnovillo@google.com>
  5. This file is part of GCC.
  6. GCC is free software; you can redistribute it and/or modify it under
  7. the terms of the GNU General Public License as published by the Free
  8. Software Foundation; either version 3, or (at your option) any later
  9. version.
  10. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  13. for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with GCC; see the file COPYING3. If not see
  16. <http://www.gnu.org/licenses/>. */
  17. #include "config.h"
  18. #include "system.h"
  19. #include "coretypes.h"
  20. #include "dumpfile.h"
  21. #include "backend.h"
  22. #include "tree.h"
  23. #include "gimple.h"
  24. #include "gimple-predict.h"
  25. #include "ssa.h"
  26. #include "cgraph.h"
  27. #include "gimple-pretty-print.h"
  28. #include "internal-fn.h"
  29. #include "tree-eh.h"
  30. #include "gimple-iterator.h"
  31. #include "tree-cfg.h"
  32. #include "dumpfile.h" /* for dump_flags */
  33. #include "value-prof.h"
  34. #include "trans-mem.h"
  35. #include "cfganal.h"
  36. #include "stringpool.h"
  37. #include "attribs.h"
  38. #include "asan.h"
  39. #include "cfgloop.h"
  40. /* Disable warnings about quoting issues in the pp_xxx calls below
  41. that (intentionally) don't follow GCC diagnostic conventions. */
  42. #if __GNUC__ >= 10
  43. # pragma GCC diagnostic push
  44. # pragma GCC diagnostic ignored "-Wformat-diag"
  45. #endif
  46. #define INDENT(SPACE) \
  47. do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
  48. #define GIMPLE_NIY do_niy (buffer,gs)
  49. /* Try to print on BUFFER a default message for the unrecognized
  50. gimple statement GS. */
  51. static void
  52. do_niy (pretty_printer *buffer, const gimple *gs)
  53. {
  54. pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
  55. gimple_code_name[(int) gimple_code (gs)]);
  56. }
  57. /* Emit a newline and SPC indentation spaces to BUFFER. */
  58. static void
  59. newline_and_indent (pretty_printer *buffer, int spc)
  60. {
  61. pp_newline (buffer);
  62. INDENT (spc);
  63. }
  64. /* Print the GIMPLE statement GS on stderr. */
  65. DEBUG_FUNCTION void
  66. debug_gimple_stmt (gimple *gs)
  67. {
  68. print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
  69. }
  70. /* Return formatted string of a VALUE probability
  71. (biased by REG_BR_PROB_BASE). Returned string is allocated
  72. by xstrdup_for_dump. */
  73. static const char *
  74. dump_profile (profile_count &count)
  75. {
  76. char *buf = NULL;
  77. if (!count.initialized_p ())
  78. return "";
  79. if (count.ipa_p ())
  80. buf = xasprintf ("[count: %" PRId64 "]",
  81. count.to_gcov_type ());
  82. else if (count.initialized_p ())
  83. buf = xasprintf ("[local count: %" PRId64 "]",
  84. count.to_gcov_type ());
  85. const char *ret = xstrdup_for_dump (buf);
  86. free (buf);
  87. return ret;
  88. }
  89. /* Return formatted string of a VALUE probability
  90. (biased by REG_BR_PROB_BASE). Returned string is allocated
  91. by xstrdup_for_dump. */
  92. static const char *
  93. dump_probability (profile_probability probability)
  94. {
  95. float minimum = 0.01f;
  96. float fvalue = -1;
  97. if (probability.initialized_p ())
  98. {
  99. fvalue = probability.to_reg_br_prob_base () * 100.0f / REG_BR_PROB_BASE;
  100. if (fvalue < minimum && probability.to_reg_br_prob_base ())
  101. fvalue = minimum;
  102. }
  103. char *buf;
  104. if (probability.initialized_p ())
  105. buf = xasprintf ("[%.2f%%]", fvalue);
  106. else
  107. buf = xasprintf ("[INV]");
  108. const char *ret = xstrdup_for_dump (buf);
  109. free (buf);
  110. return ret;
  111. }
  112. /* Dump E probability to BUFFER. */
  113. static void
  114. dump_edge_probability (pretty_printer *buffer, edge e)
  115. {
  116. pp_scalar (buffer, " %s", dump_probability (e->probability));
  117. }
  118. /* Print GIMPLE statement G to FILE using SPC indentation spaces and
  119. FLAGS as in pp_gimple_stmt_1. */
  120. void
  121. print_gimple_stmt (FILE *file, gimple *g, int spc, dump_flags_t flags)
  122. {
  123. pretty_printer buffer;
  124. pp_needs_newline (&buffer) = true;
  125. buffer.buffer->stream = file;
  126. pp_gimple_stmt_1 (&buffer, g, spc, flags);
  127. pp_newline_and_flush (&buffer);
  128. }
  129. DEBUG_FUNCTION void
  130. debug (gimple &ref)
  131. {
  132. print_gimple_stmt (stderr, &ref, 0, TDF_NONE);
  133. }
  134. DEBUG_FUNCTION void
  135. debug (gimple *ptr)
  136. {
  137. if (ptr)
  138. debug (*ptr);
  139. else
  140. fprintf (stderr, "<nil>\n");
  141. }
  142. /* Print GIMPLE statement G to FILE using SPC indentation spaces and
  143. FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
  144. of the statement. */
  145. void
  146. print_gimple_expr (FILE *file, gimple *g, int spc, dump_flags_t flags)
  147. {
  148. flags |= TDF_RHS_ONLY;
  149. pretty_printer buffer;
  150. pp_needs_newline (&buffer) = true;
  151. buffer.buffer->stream = file;
  152. pp_gimple_stmt_1 (&buffer, g, spc, flags);
  153. pp_flush (&buffer);
  154. }
  155. /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
  156. spaces and FLAGS as in pp_gimple_stmt_1.
  157. The caller is responsible for calling pp_flush on BUFFER to finalize
  158. the pretty printer. */
  159. static void
  160. dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc,
  161. dump_flags_t flags)
  162. {
  163. gimple_stmt_iterator i;
  164. for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
  165. {
  166. gimple *gs = gsi_stmt (i);
  167. INDENT (spc);
  168. pp_gimple_stmt_1 (buffer, gs, spc, flags);
  169. if (!gsi_one_before_end_p (i))
  170. pp_newline (buffer);
  171. }
  172. }
  173. /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
  174. FLAGS as in pp_gimple_stmt_1. */
  175. void
  176. print_gimple_seq (FILE *file, gimple_seq seq, int spc, dump_flags_t flags)
  177. {
  178. pretty_printer buffer;
  179. pp_needs_newline (&buffer) = true;
  180. buffer.buffer->stream = file;
  181. dump_gimple_seq (&buffer, seq, spc, flags);
  182. pp_newline_and_flush (&buffer);
  183. }
  184. /* Print the GIMPLE sequence SEQ on stderr. */
  185. DEBUG_FUNCTION void
  186. debug_gimple_seq (gimple_seq seq)
  187. {
  188. print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
  189. }
  190. /* A simple helper to pretty-print some of the gimple tuples in the printf
  191. style. The format modifiers are preceded by '%' and are:
  192. 'G' - outputs a string corresponding to the code of the given gimple,
  193. 'S' - outputs a gimple_seq with indent of spc + 2,
  194. 'T' - outputs the tree t,
  195. 'd' - outputs an int as a decimal,
  196. 's' - outputs a string,
  197. 'n' - outputs a newline,
  198. 'x' - outputs an int as hexadecimal,
  199. '+' - increases indent by 2 then outputs a newline,
  200. '-' - decreases indent by 2 then outputs a newline. */
  201. static void
  202. dump_gimple_fmt (pretty_printer *buffer, int spc, dump_flags_t flags,
  203. const char *fmt, ...)
  204. {
  205. va_list args;
  206. const char *c;
  207. const char *tmp;
  208. va_start (args, fmt);
  209. for (c = fmt; *c; c++)
  210. {
  211. if (*c == '%')
  212. {
  213. gimple_seq seq;
  214. tree t;
  215. gimple *g;
  216. switch (*++c)
  217. {
  218. case 'G':
  219. g = va_arg (args, gimple *);
  220. tmp = gimple_code_name[gimple_code (g)];
  221. pp_string (buffer, tmp);
  222. break;
  223. case 'S':
  224. seq = va_arg (args, gimple_seq);
  225. pp_newline (buffer);
  226. dump_gimple_seq (buffer, seq, spc + 2, flags);
  227. newline_and_indent (buffer, spc);
  228. break;
  229. case 'T':
  230. t = va_arg (args, tree);
  231. if (t == NULL_TREE)
  232. pp_string (buffer, "NULL");
  233. else
  234. dump_generic_node (buffer, t, spc, flags, false);
  235. break;
  236. case 'd':
  237. pp_decimal_int (buffer, va_arg (args, int));
  238. break;
  239. case 's':
  240. pp_string (buffer, va_arg (args, char *));
  241. break;
  242. case 'n':
  243. newline_and_indent (buffer, spc);
  244. break;
  245. case 'x':
  246. pp_scalar (buffer, "%x", va_arg (args, int));
  247. break;
  248. case '+':
  249. spc += 2;
  250. newline_and_indent (buffer, spc);
  251. break;
  252. case '-':
  253. spc -= 2;
  254. newline_and_indent (buffer, spc);
  255. break;
  256. default:
  257. gcc_unreachable ();
  258. }
  259. }
  260. else
  261. pp_character (buffer, *c);
  262. }
  263. va_end (args);
  264. }
  265. /* Helper for dump_gimple_assign. Print the unary RHS of the
  266. assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
  267. static void
  268. dump_unary_rhs (pretty_printer *buffer, const gassign *gs, int spc,
  269. dump_flags_t flags)
  270. {
  271. enum tree_code rhs_code = gimple_assign_rhs_code (gs);
  272. tree lhs = gimple_assign_lhs (gs);
  273. tree rhs = gimple_assign_rhs1 (gs);
  274. switch (rhs_code)
  275. {
  276. case VIEW_CONVERT_EXPR:
  277. case ASSERT_EXPR:
  278. dump_generic_node (buffer, rhs, spc, flags, false);
  279. break;
  280. case FIXED_CONVERT_EXPR:
  281. case ADDR_SPACE_CONVERT_EXPR:
  282. case FIX_TRUNC_EXPR:
  283. case FLOAT_EXPR:
  284. CASE_CONVERT:
  285. pp_left_paren (buffer);
  286. dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
  287. pp_string (buffer, ") ");
  288. if (op_prio (rhs) < op_code_prio (rhs_code))
  289. {
  290. pp_left_paren (buffer);
  291. dump_generic_node (buffer, rhs, spc, flags, false);
  292. pp_right_paren (buffer);
  293. }
  294. else
  295. dump_generic_node (buffer, rhs, spc, flags, false);
  296. break;
  297. case PAREN_EXPR:
  298. pp_string (buffer, "((");
  299. dump_generic_node (buffer, rhs, spc, flags, false);
  300. pp_string (buffer, "))");
  301. break;
  302. case ABS_EXPR:
  303. case ABSU_EXPR:
  304. if (flags & TDF_GIMPLE)
  305. {
  306. pp_string (buffer,
  307. rhs_code == ABS_EXPR ? "__ABS " : "__ABSU ");
  308. dump_generic_node (buffer, rhs, spc, flags, false);
  309. }
  310. else
  311. {
  312. pp_string (buffer,
  313. rhs_code == ABS_EXPR ? "ABS_EXPR <" : "ABSU_EXPR <");
  314. dump_generic_node (buffer, rhs, spc, flags, false);
  315. pp_greater (buffer);
  316. }
  317. break;
  318. default:
  319. if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
  320. || TREE_CODE_CLASS (rhs_code) == tcc_constant
  321. || TREE_CODE_CLASS (rhs_code) == tcc_reference
  322. || rhs_code == SSA_NAME
  323. || rhs_code == ADDR_EXPR
  324. || rhs_code == CONSTRUCTOR)
  325. {
  326. dump_generic_node (buffer, rhs, spc, flags, false);
  327. break;
  328. }
  329. else if (rhs_code == BIT_NOT_EXPR)
  330. pp_complement (buffer);
  331. else if (rhs_code == TRUTH_NOT_EXPR)
  332. pp_exclamation (buffer);
  333. else if (rhs_code == NEGATE_EXPR)
  334. pp_minus (buffer);
  335. else
  336. {
  337. pp_left_bracket (buffer);
  338. pp_string (buffer, get_tree_code_name (rhs_code));
  339. pp_string (buffer, "] ");
  340. }
  341. if (op_prio (rhs) < op_code_prio (rhs_code))
  342. {
  343. pp_left_paren (buffer);
  344. dump_generic_node (buffer, rhs, spc, flags, false);
  345. pp_right_paren (buffer);
  346. }
  347. else
  348. dump_generic_node (buffer, rhs, spc, flags, false);
  349. break;
  350. }
  351. }
  352. /* Helper for dump_gimple_assign. Print the binary RHS of the
  353. assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
  354. static void
  355. dump_binary_rhs (pretty_printer *buffer, const gassign *gs, int spc,
  356. dump_flags_t flags)
  357. {
  358. const char *p;
  359. enum tree_code code = gimple_assign_rhs_code (gs);
  360. switch (code)
  361. {
  362. case MIN_EXPR:
  363. case MAX_EXPR:
  364. if (flags & TDF_GIMPLE)
  365. {
  366. pp_string (buffer, code == MIN_EXPR ? "__MIN (" : "__MAX (");
  367. dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
  368. false);
  369. pp_string (buffer, ", ");
  370. dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
  371. false);
  372. pp_string (buffer, ")");
  373. break;
  374. }
  375. else
  376. gcc_fallthrough ();
  377. case COMPLEX_EXPR:
  378. case VEC_WIDEN_MULT_HI_EXPR:
  379. case VEC_WIDEN_MULT_LO_EXPR:
  380. case VEC_WIDEN_MULT_EVEN_EXPR:
  381. case VEC_WIDEN_MULT_ODD_EXPR:
  382. case VEC_PACK_TRUNC_EXPR:
  383. case VEC_PACK_SAT_EXPR:
  384. case VEC_PACK_FIX_TRUNC_EXPR:
  385. case VEC_PACK_FLOAT_EXPR:
  386. case VEC_WIDEN_LSHIFT_HI_EXPR:
  387. case VEC_WIDEN_LSHIFT_LO_EXPR:
  388. case VEC_SERIES_EXPR:
  389. for (p = get_tree_code_name (code); *p; p++)
  390. pp_character (buffer, TOUPPER (*p));
  391. pp_string (buffer, " <");
  392. dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
  393. pp_string (buffer, ", ");
  394. dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
  395. pp_greater (buffer);
  396. break;
  397. default:
  398. if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
  399. {
  400. pp_left_paren (buffer);
  401. dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
  402. false);
  403. pp_right_paren (buffer);
  404. }
  405. else
  406. dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
  407. pp_space (buffer);
  408. pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
  409. pp_space (buffer);
  410. if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
  411. {
  412. pp_left_paren (buffer);
  413. dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
  414. false);
  415. pp_right_paren (buffer);
  416. }
  417. else
  418. dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
  419. }
  420. }
  421. /* Helper for dump_gimple_assign. Print the ternary RHS of the
  422. assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
  423. static void
  424. dump_ternary_rhs (pretty_printer *buffer, const gassign *gs, int spc,
  425. dump_flags_t flags)
  426. {
  427. const char *p;
  428. enum tree_code code = gimple_assign_rhs_code (gs);
  429. switch (code)
  430. {
  431. case WIDEN_MULT_PLUS_EXPR:
  432. case WIDEN_MULT_MINUS_EXPR:
  433. for (p = get_tree_code_name (code); *p; p++)
  434. pp_character (buffer, TOUPPER (*p));
  435. pp_string (buffer, " <");
  436. dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
  437. pp_string (buffer, ", ");
  438. dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
  439. pp_string (buffer, ", ");
  440. dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
  441. pp_greater (buffer);
  442. break;
  443. case DOT_PROD_EXPR:
  444. pp_string (buffer, "DOT_PROD_EXPR <");
  445. dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
  446. pp_string (buffer, ", ");
  447. dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
  448. pp_string (buffer, ", ");
  449. dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
  450. pp_greater (buffer);
  451. break;
  452. case SAD_EXPR:
  453. pp_string (buffer, "SAD_EXPR <");
  454. dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
  455. pp_string (buffer, ", ");
  456. dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
  457. pp_string (buffer, ", ");
  458. dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
  459. pp_greater (buffer);
  460. break;
  461. case VEC_PERM_EXPR:
  462. if (flags & TDF_GIMPLE)
  463. pp_string (buffer, "__VEC_PERM (");
  464. else
  465. pp_string (buffer, "VEC_PERM_EXPR <");
  466. dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
  467. pp_string (buffer, ", ");
  468. dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
  469. pp_string (buffer, ", ");
  470. dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
  471. if (flags & TDF_GIMPLE)
  472. pp_right_paren (buffer);
  473. else
  474. pp_greater (buffer);
  475. break;
  476. case REALIGN_LOAD_EXPR:
  477. pp_string (buffer, "REALIGN_LOAD <");
  478. dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
  479. pp_string (buffer, ", ");
  480. dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
  481. pp_string (buffer, ", ");
  482. dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
  483. pp_greater (buffer);
  484. break;
  485. case COND_EXPR:
  486. dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
  487. pp_string (buffer, " ? ");
  488. dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
  489. pp_string (buffer, " : ");
  490. dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
  491. break;
  492. case VEC_COND_EXPR:
  493. pp_string (buffer, "VEC_COND_EXPR <");
  494. dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
  495. pp_string (buffer, ", ");
  496. dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
  497. pp_string (buffer, ", ");
  498. dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
  499. pp_greater (buffer);
  500. break;
  501. case BIT_INSERT_EXPR:
  502. if (flags & TDF_GIMPLE)
  503. {
  504. pp_string (buffer, "__BIT_INSERT (");
  505. dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc,
  506. flags | TDF_SLIM, false);
  507. pp_string (buffer, ", ");
  508. dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc,
  509. flags | TDF_SLIM, false);
  510. pp_string (buffer, ", ");
  511. dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc,
  512. flags | TDF_SLIM, false);
  513. pp_right_paren (buffer);
  514. }
  515. else
  516. {
  517. pp_string (buffer, "BIT_INSERT_EXPR <");
  518. dump_generic_node (buffer, gimple_assign_rhs1 (gs),
  519. spc, flags, false);
  520. pp_string (buffer, ", ");
  521. dump_generic_node (buffer, gimple_assign_rhs2 (gs),
  522. spc, flags, false);
  523. pp_string (buffer, ", ");
  524. dump_generic_node (buffer, gimple_assign_rhs3 (gs),
  525. spc, flags, false);
  526. if (INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_rhs2 (gs))))
  527. {
  528. pp_string (buffer, " (");
  529. pp_decimal_int (buffer, TYPE_PRECISION
  530. (TREE_TYPE (gimple_assign_rhs2 (gs))));
  531. pp_string (buffer, " bits)");
  532. }
  533. pp_greater (buffer);
  534. }
  535. break;
  536. default:
  537. gcc_unreachable ();
  538. }
  539. }
  540. /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
  541. pp_gimple_stmt_1. */
  542. static void
  543. dump_gimple_assign (pretty_printer *buffer, const gassign *gs, int spc,
  544. dump_flags_t flags)
  545. {
  546. if (flags & TDF_RAW)
  547. {
  548. tree arg1 = NULL;
  549. tree arg2 = NULL;
  550. tree arg3 = NULL;
  551. switch (gimple_num_ops (gs))
  552. {
  553. case 4:
  554. arg3 = gimple_assign_rhs3 (gs);
  555. /* FALLTHRU */
  556. case 3:
  557. arg2 = gimple_assign_rhs2 (gs);
  558. /* FALLTHRU */
  559. case 2:
  560. arg1 = gimple_assign_rhs1 (gs);
  561. break;
  562. default:
  563. gcc_unreachable ();
  564. }
  565. dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
  566. get_tree_code_name (gimple_assign_rhs_code (gs)),
  567. gimple_assign_lhs (gs), arg1, arg2, arg3);
  568. }
  569. else
  570. {
  571. if (!(flags & TDF_RHS_ONLY))
  572. {
  573. dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
  574. pp_space (buffer);
  575. pp_equal (buffer);
  576. if (gimple_assign_nontemporal_move_p (gs))
  577. pp_string (buffer, "{nt}");
  578. if (gimple_has_volatile_ops (gs))
  579. pp_string (buffer, "{v}");
  580. pp_space (buffer);
  581. }
  582. if (gimple_num_ops (gs) == 2)
  583. dump_unary_rhs (buffer, gs, spc, flags);
  584. else if (gimple_num_ops (gs) == 3)
  585. dump_binary_rhs (buffer, gs, spc, flags);
  586. else if (gimple_num_ops (gs) == 4)
  587. dump_ternary_rhs (buffer, gs, spc, flags);
  588. else
  589. gcc_unreachable ();
  590. if (!(flags & TDF_RHS_ONLY))
  591. pp_semicolon (buffer);
  592. }
  593. }
  594. /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
  595. pp_gimple_stmt_1. */
  596. static void
  597. dump_gimple_return (pretty_printer *buffer, const greturn *gs, int spc,
  598. dump_flags_t flags)
  599. {
  600. tree t;
  601. t = gimple_return_retval (gs);
  602. if (flags & TDF_RAW)
  603. dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, t);
  604. else
  605. {
  606. pp_string (buffer, "return");
  607. if (t)
  608. {
  609. pp_space (buffer);
  610. dump_generic_node (buffer, t, spc, flags, false);
  611. }
  612. pp_semicolon (buffer);
  613. }
  614. }
  615. /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
  616. dump_gimple_call. */
  617. static void
  618. dump_gimple_call_args (pretty_printer *buffer, const gcall *gs,
  619. dump_flags_t flags)
  620. {
  621. size_t i = 0;
  622. /* Pretty print first arg to certain internal fns. */
  623. if (gimple_call_internal_p (gs))
  624. {
  625. const char *const *enums = NULL;
  626. unsigned limit = 0;
  627. switch (gimple_call_internal_fn (gs))
  628. {
  629. case IFN_UNIQUE:
  630. #define DEF(X) #X
  631. static const char *const unique_args[] = {IFN_UNIQUE_CODES};
  632. #undef DEF
  633. enums = unique_args;
  634. limit = ARRAY_SIZE (unique_args);
  635. break;
  636. case IFN_GOACC_LOOP:
  637. #define DEF(X) #X
  638. static const char *const loop_args[] = {IFN_GOACC_LOOP_CODES};
  639. #undef DEF
  640. enums = loop_args;
  641. limit = ARRAY_SIZE (loop_args);
  642. break;
  643. case IFN_GOACC_REDUCTION:
  644. #define DEF(X) #X
  645. static const char *const reduction_args[]
  646. = {IFN_GOACC_REDUCTION_CODES};
  647. #undef DEF
  648. enums = reduction_args;
  649. limit = ARRAY_SIZE (reduction_args);
  650. break;
  651. case IFN_ASAN_MARK:
  652. #define DEF(X) #X
  653. static const char *const asan_mark_args[] = {IFN_ASAN_MARK_FLAGS};
  654. #undef DEF
  655. enums = asan_mark_args;
  656. limit = ARRAY_SIZE (asan_mark_args);
  657. break;
  658. default:
  659. break;
  660. }
  661. if (limit)
  662. {
  663. tree arg0 = gimple_call_arg (gs, 0);
  664. HOST_WIDE_INT v;
  665. if (TREE_CODE (arg0) == INTEGER_CST
  666. && tree_fits_shwi_p (arg0)
  667. && (v = tree_to_shwi (arg0)) >= 0 && v < limit)
  668. {
  669. i++;
  670. pp_string (buffer, enums[v]);
  671. }
  672. }
  673. }
  674. for (; i < gimple_call_num_args (gs); i++)
  675. {
  676. if (i)
  677. pp_string (buffer, ", ");
  678. dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
  679. }
  680. if (gimple_call_va_arg_pack_p (gs))
  681. {
  682. if (i)
  683. pp_string (buffer, ", ");
  684. pp_string (buffer, "__builtin_va_arg_pack ()");
  685. }
  686. }
  687. /* Dump the points-to solution *PT to BUFFER. */
  688. static void
  689. pp_points_to_solution (pretty_printer *buffer, const pt_solution *pt)
  690. {
  691. if (pt->anything)
  692. {
  693. pp_string (buffer, "anything ");
  694. return;
  695. }
  696. if (pt->nonlocal)
  697. pp_string (buffer, "nonlocal ");
  698. if (pt->escaped)
  699. pp_string (buffer, "escaped ");
  700. if (pt->ipa_escaped)
  701. pp_string (buffer, "unit-escaped ");
  702. if (pt->null)
  703. pp_string (buffer, "null ");
  704. if (pt->vars
  705. && !bitmap_empty_p (pt->vars))
  706. {
  707. bitmap_iterator bi;
  708. unsigned i;
  709. pp_string (buffer, "{ ");
  710. EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
  711. {
  712. pp_string (buffer, "D.");
  713. pp_decimal_int (buffer, i);
  714. pp_space (buffer);
  715. }
  716. pp_right_brace (buffer);
  717. if (pt->vars_contains_nonlocal
  718. || pt->vars_contains_escaped
  719. || pt->vars_contains_escaped_heap
  720. || pt->vars_contains_restrict)
  721. {
  722. const char *comma = "";
  723. pp_string (buffer, " (");
  724. if (pt->vars_contains_nonlocal)
  725. {
  726. pp_string (buffer, "nonlocal");
  727. comma = ", ";
  728. }
  729. if (pt->vars_contains_escaped)
  730. {
  731. pp_string (buffer, comma);
  732. pp_string (buffer, "escaped");
  733. comma = ", ";
  734. }
  735. if (pt->vars_contains_escaped_heap)
  736. {
  737. pp_string (buffer, comma);
  738. pp_string (buffer, "escaped heap");
  739. comma = ", ";
  740. }
  741. if (pt->vars_contains_restrict)
  742. {
  743. pp_string (buffer, comma);
  744. pp_string (buffer, "restrict");
  745. comma = ", ";
  746. }
  747. if (pt->vars_contains_interposable)
  748. {
  749. pp_string (buffer, comma);
  750. pp_string (buffer, "interposable");
  751. }
  752. pp_string (buffer, ")");
  753. }
  754. }
  755. }
  756. /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
  757. pp_gimple_stmt_1. */
  758. static void
  759. dump_gimple_call (pretty_printer *buffer, const gcall *gs, int spc,
  760. dump_flags_t flags)
  761. {
  762. tree lhs = gimple_call_lhs (gs);
  763. tree fn = gimple_call_fn (gs);
  764. if (flags & TDF_ALIAS)
  765. {
  766. const pt_solution *pt;
  767. pt = gimple_call_use_set (gs);
  768. if (!pt_solution_empty_p (pt))
  769. {
  770. pp_string (buffer, "# USE = ");
  771. pp_points_to_solution (buffer, pt);
  772. newline_and_indent (buffer, spc);
  773. }
  774. pt = gimple_call_clobber_set (gs);
  775. if (!pt_solution_empty_p (pt))
  776. {
  777. pp_string (buffer, "# CLB = ");
  778. pp_points_to_solution (buffer, pt);
  779. newline_and_indent (buffer, spc);
  780. }
  781. }
  782. if (flags & TDF_RAW)
  783. {
  784. if (gimple_call_internal_p (gs))
  785. dump_gimple_fmt (buffer, spc, flags, "%G <.%s, %T", gs,
  786. internal_fn_name (gimple_call_internal_fn (gs)), lhs);
  787. else
  788. dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
  789. if (gimple_call_num_args (gs) > 0)
  790. {
  791. pp_string (buffer, ", ");
  792. dump_gimple_call_args (buffer, gs, flags);
  793. }
  794. pp_greater (buffer);
  795. }
  796. else
  797. {
  798. if (lhs && !(flags & TDF_RHS_ONLY))
  799. {
  800. dump_generic_node (buffer, lhs, spc, flags, false);
  801. pp_string (buffer, " =");
  802. if (gimple_has_volatile_ops (gs))
  803. pp_string (buffer, "{v}");
  804. pp_space (buffer);
  805. }
  806. if (gimple_call_internal_p (gs))
  807. {
  808. pp_dot (buffer);
  809. pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
  810. }
  811. else
  812. print_call_name (buffer, fn, flags);
  813. pp_string (buffer, " (");
  814. dump_gimple_call_args (buffer, gs, flags);
  815. pp_right_paren (buffer);
  816. if (!(flags & TDF_RHS_ONLY))
  817. pp_semicolon (buffer);
  818. }
  819. if (gimple_call_chain (gs))
  820. {
  821. pp_string (buffer, " [static-chain: ");
  822. dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
  823. pp_right_bracket (buffer);
  824. }
  825. if (gimple_call_return_slot_opt_p (gs))
  826. pp_string (buffer, " [return slot optimization]");
  827. if (gimple_call_tail_p (gs))
  828. pp_string (buffer, " [tail call]");
  829. if (gimple_call_must_tail_p (gs))
  830. pp_string (buffer, " [must tail call]");
  831. if (fn == NULL)
  832. return;
  833. /* Dump the arguments of _ITM_beginTransaction sanely. */
  834. if (TREE_CODE (fn) == ADDR_EXPR)
  835. fn = TREE_OPERAND (fn, 0);
  836. if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
  837. pp_string (buffer, " [tm-clone]");
  838. if (TREE_CODE (fn) == FUNCTION_DECL
  839. && fndecl_built_in_p (fn, BUILT_IN_TM_START)
  840. && gimple_call_num_args (gs) > 0)
  841. {
  842. tree t = gimple_call_arg (gs, 0);
  843. unsigned HOST_WIDE_INT props;
  844. gcc_assert (TREE_CODE (t) == INTEGER_CST);
  845. pp_string (buffer, " [ ");
  846. /* Get the transaction code properties. */
  847. props = TREE_INT_CST_LOW (t);
  848. if (props & PR_INSTRUMENTEDCODE)
  849. pp_string (buffer, "instrumentedCode ");
  850. if (props & PR_UNINSTRUMENTEDCODE)
  851. pp_string (buffer, "uninstrumentedCode ");
  852. if (props & PR_HASNOXMMUPDATE)
  853. pp_string (buffer, "hasNoXMMUpdate ");
  854. if (props & PR_HASNOABORT)
  855. pp_string (buffer, "hasNoAbort ");
  856. if (props & PR_HASNOIRREVOCABLE)
  857. pp_string (buffer, "hasNoIrrevocable ");
  858. if (props & PR_DOESGOIRREVOCABLE)
  859. pp_string (buffer, "doesGoIrrevocable ");
  860. if (props & PR_HASNOSIMPLEREADS)
  861. pp_string (buffer, "hasNoSimpleReads ");
  862. if (props & PR_AWBARRIERSOMITTED)
  863. pp_string (buffer, "awBarriersOmitted ");
  864. if (props & PR_RARBARRIERSOMITTED)
  865. pp_string (buffer, "RaRBarriersOmitted ");
  866. if (props & PR_UNDOLOGCODE)
  867. pp_string (buffer, "undoLogCode ");
  868. if (props & PR_PREFERUNINSTRUMENTED)
  869. pp_string (buffer, "preferUninstrumented ");
  870. if (props & PR_EXCEPTIONBLOCK)
  871. pp_string (buffer, "exceptionBlock ");
  872. if (props & PR_HASELSE)
  873. pp_string (buffer, "hasElse ");
  874. if (props & PR_READONLY)
  875. pp_string (buffer, "readOnly ");
  876. pp_right_bracket (buffer);
  877. }
  878. }
  879. /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
  880. pp_gimple_stmt_1. */
  881. static void
  882. dump_gimple_switch (pretty_printer *buffer, const gswitch *gs, int spc,
  883. dump_flags_t flags)
  884. {
  885. unsigned int i;
  886. GIMPLE_CHECK (gs, GIMPLE_SWITCH);
  887. if (flags & TDF_RAW)
  888. dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
  889. gimple_switch_index (gs));
  890. else
  891. {
  892. pp_string (buffer, "switch (");
  893. dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
  894. if (flags & TDF_GIMPLE)
  895. pp_string (buffer, ") {");
  896. else
  897. pp_string (buffer, ") <");
  898. }
  899. for (i = 0; i < gimple_switch_num_labels (gs); i++)
  900. {
  901. tree case_label = gimple_switch_label (gs, i);
  902. gcc_checking_assert (case_label != NULL_TREE);
  903. dump_generic_node (buffer, case_label, spc, flags, false);
  904. pp_space (buffer);
  905. tree label = CASE_LABEL (case_label);
  906. dump_generic_node (buffer, label, spc, flags, false);
  907. if (cfun && cfun->cfg)
  908. {
  909. basic_block dest = label_to_block (cfun, label);
  910. if (dest)
  911. {
  912. edge label_edge = find_edge (gimple_bb (gs), dest);
  913. if (label_edge && !(flags & TDF_GIMPLE))
  914. dump_edge_probability (buffer, label_edge);
  915. }
  916. }
  917. if (i < gimple_switch_num_labels (gs) - 1)
  918. {
  919. if (flags & TDF_GIMPLE)
  920. pp_string (buffer, "; ");
  921. else
  922. pp_string (buffer, ", ");
  923. }
  924. }
  925. if (flags & TDF_GIMPLE)
  926. pp_string (buffer, "; }");
  927. else
  928. pp_greater (buffer);
  929. }
  930. /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
  931. pp_gimple_stmt_1. */
  932. static void
  933. dump_gimple_cond (pretty_printer *buffer, const gcond *gs, int spc,
  934. dump_flags_t flags)
  935. {
  936. if (flags & TDF_RAW)
  937. dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
  938. get_tree_code_name (gimple_cond_code (gs)),
  939. gimple_cond_lhs (gs), gimple_cond_rhs (gs),
  940. gimple_cond_true_label (gs), gimple_cond_false_label (gs));
  941. else
  942. {
  943. if (!(flags & TDF_RHS_ONLY))
  944. pp_string (buffer, "if (");
  945. dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
  946. pp_space (buffer);
  947. pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
  948. pp_space (buffer);
  949. dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
  950. if (!(flags & TDF_RHS_ONLY))
  951. {
  952. edge_iterator ei;
  953. edge e, true_edge = NULL, false_edge = NULL;
  954. basic_block bb = gimple_bb (gs);
  955. if (bb)
  956. {
  957. FOR_EACH_EDGE (e, ei, bb->succs)
  958. {
  959. if (e->flags & EDGE_TRUE_VALUE)
  960. true_edge = e;
  961. else if (e->flags & EDGE_FALSE_VALUE)
  962. false_edge = e;
  963. }
  964. }
  965. bool has_edge_info = true_edge != NULL && false_edge != NULL;
  966. pp_right_paren (buffer);
  967. if (gimple_cond_true_label (gs))
  968. {
  969. pp_string (buffer, " goto ");
  970. dump_generic_node (buffer, gimple_cond_true_label (gs),
  971. spc, flags, false);
  972. if (has_edge_info && !(flags & TDF_GIMPLE))
  973. dump_edge_probability (buffer, true_edge);
  974. pp_semicolon (buffer);
  975. }
  976. if (gimple_cond_false_label (gs))
  977. {
  978. pp_string (buffer, " else goto ");
  979. dump_generic_node (buffer, gimple_cond_false_label (gs),
  980. spc, flags, false);
  981. if (has_edge_info && !(flags & TDF_GIMPLE))
  982. dump_edge_probability (buffer, false_edge);
  983. pp_semicolon (buffer);
  984. }
  985. }
  986. }
  987. }
  988. /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
  989. spaces of indent. FLAGS specifies details to show in the dump (see
  990. TDF_* in dumpfils.h). */
  991. static void
  992. dump_gimple_label (pretty_printer *buffer, const glabel *gs, int spc,
  993. dump_flags_t flags)
  994. {
  995. tree label = gimple_label_label (gs);
  996. if (flags & TDF_RAW)
  997. dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
  998. else
  999. {
  1000. dump_generic_node (buffer, label, spc, flags, false);
  1001. pp_colon (buffer);
  1002. }
  1003. if (flags & TDF_GIMPLE)
  1004. return;
  1005. if (DECL_NONLOCAL (label))
  1006. pp_string (buffer, " [non-local]");
  1007. if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
  1008. pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
  1009. }
  1010. /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
  1011. spaces of indent. FLAGS specifies details to show in the dump (see
  1012. TDF_* in dumpfile.h). */
  1013. static void
  1014. dump_gimple_goto (pretty_printer *buffer, const ggoto *gs, int spc,
  1015. dump_flags_t flags)
  1016. {
  1017. tree label = gimple_goto_dest (gs);
  1018. if (flags & TDF_RAW)
  1019. dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
  1020. else
  1021. dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
  1022. }
  1023. /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
  1024. spaces of indent. FLAGS specifies details to show in the dump (see
  1025. TDF_* in dumpfile.h). */
  1026. static void
  1027. dump_gimple_bind (pretty_printer *buffer, const gbind *gs, int spc,
  1028. dump_flags_t flags)
  1029. {
  1030. if (flags & TDF_RAW)
  1031. dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
  1032. else
  1033. pp_left_brace (buffer);
  1034. if (!(flags & TDF_SLIM))
  1035. {
  1036. tree var;
  1037. for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
  1038. {
  1039. newline_and_indent (buffer, 2);
  1040. print_declaration (buffer, var, spc, flags);
  1041. }
  1042. if (gimple_bind_vars (gs))
  1043. pp_newline (buffer);
  1044. }
  1045. pp_newline (buffer);
  1046. dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
  1047. newline_and_indent (buffer, spc);
  1048. if (flags & TDF_RAW)
  1049. pp_greater (buffer);
  1050. else
  1051. pp_right_brace (buffer);
  1052. }
  1053. /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
  1054. indent. FLAGS specifies details to show in the dump (see TDF_* in
  1055. dumpfile.h). */
  1056. static void
  1057. dump_gimple_try (pretty_printer *buffer, const gtry *gs, int spc,
  1058. dump_flags_t flags)
  1059. {
  1060. if (flags & TDF_RAW)
  1061. {
  1062. const char *type;
  1063. if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
  1064. type = "GIMPLE_TRY_CATCH";
  1065. else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
  1066. type = "GIMPLE_TRY_FINALLY";
  1067. else
  1068. type = "UNKNOWN GIMPLE_TRY";
  1069. dump_gimple_fmt (buffer, spc, flags,
  1070. "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
  1071. gimple_try_eval (gs), gimple_try_cleanup (gs));
  1072. }
  1073. else
  1074. {
  1075. pp_string (buffer, "try");
  1076. newline_and_indent (buffer, spc + 2);
  1077. pp_left_brace (buffer);
  1078. pp_newline (buffer);
  1079. dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
  1080. newline_and_indent (buffer, spc + 2);
  1081. pp_right_brace (buffer);
  1082. gimple_seq seq = gimple_try_cleanup (gs);
  1083. if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
  1084. {
  1085. newline_and_indent (buffer, spc);
  1086. pp_string (buffer, "catch");
  1087. newline_and_indent (buffer, spc + 2);
  1088. pp_left_brace (buffer);
  1089. }
  1090. else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
  1091. {
  1092. newline_and_indent (buffer, spc);
  1093. pp_string (buffer, "finally");
  1094. newline_and_indent (buffer, spc + 2);
  1095. pp_left_brace (buffer);
  1096. if (seq && is_a <geh_else *> (gimple_seq_first_stmt (seq))
  1097. && gimple_seq_nondebug_singleton_p (seq))
  1098. {
  1099. geh_else *stmt = as_a <geh_else *> (gimple_seq_first_stmt (seq));
  1100. seq = gimple_eh_else_n_body (stmt);
  1101. pp_newline (buffer);
  1102. dump_gimple_seq (buffer, seq, spc + 4, flags);
  1103. newline_and_indent (buffer, spc + 2);
  1104. pp_right_brace (buffer);
  1105. seq = gimple_eh_else_e_body (stmt);
  1106. newline_and_indent (buffer, spc);
  1107. pp_string (buffer, "else");
  1108. newline_and_indent (buffer, spc + 2);
  1109. pp_left_brace (buffer);
  1110. }
  1111. }
  1112. else
  1113. pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
  1114. pp_newline (buffer);
  1115. dump_gimple_seq (buffer, seq, spc + 4, flags);
  1116. newline_and_indent (buffer, spc + 2);
  1117. pp_right_brace (buffer);
  1118. }
  1119. }
  1120. /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
  1121. indent. FLAGS specifies details to show in the dump (see TDF_* in
  1122. dumpfile.h). */
  1123. static void
  1124. dump_gimple_catch (pretty_printer *buffer, const gcatch *gs, int spc,
  1125. dump_flags_t flags)
  1126. {
  1127. if (flags & TDF_RAW)
  1128. dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
  1129. gimple_catch_types (gs), gimple_catch_handler (gs));
  1130. else
  1131. dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
  1132. gimple_catch_types (gs), gimple_catch_handler (gs));
  1133. }
  1134. /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
  1135. indent. FLAGS specifies details to show in the dump (see TDF_* in
  1136. dumpfile.h). */
  1137. static void
  1138. dump_gimple_eh_filter (pretty_printer *buffer, const geh_filter *gs, int spc,
  1139. dump_flags_t flags)
  1140. {
  1141. if (flags & TDF_RAW)
  1142. dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
  1143. gimple_eh_filter_types (gs),
  1144. gimple_eh_filter_failure (gs));
  1145. else
  1146. dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
  1147. gimple_eh_filter_types (gs),
  1148. gimple_eh_filter_failure (gs));
  1149. }
  1150. /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
  1151. static void
  1152. dump_gimple_eh_must_not_throw (pretty_printer *buffer,
  1153. const geh_mnt *gs, int spc, dump_flags_t flags)
  1154. {
  1155. if (flags & TDF_RAW)
  1156. dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
  1157. gimple_eh_must_not_throw_fndecl (gs));
  1158. else
  1159. dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
  1160. gimple_eh_must_not_throw_fndecl (gs));
  1161. }
  1162. /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
  1163. indent. FLAGS specifies details to show in the dump (see TDF_* in
  1164. dumpfile.h). */
  1165. static void
  1166. dump_gimple_eh_else (pretty_printer *buffer, const geh_else *gs, int spc,
  1167. dump_flags_t flags)
  1168. {
  1169. if (flags & TDF_RAW)
  1170. dump_gimple_fmt (buffer, spc, flags,
  1171. "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
  1172. gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
  1173. else
  1174. dump_gimple_fmt (buffer, spc, flags,
  1175. "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
  1176. gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
  1177. }
  1178. /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
  1179. indent. FLAGS specifies details to show in the dump (see TDF_* in
  1180. dumpfile.h). */
  1181. static void
  1182. dump_gimple_resx (pretty_printer *buffer, const gresx *gs, int spc,
  1183. dump_flags_t flags)
  1184. {
  1185. if (flags & TDF_RAW)
  1186. dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
  1187. gimple_resx_region (gs));
  1188. else
  1189. dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
  1190. }
  1191. /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
  1192. static void
  1193. dump_gimple_eh_dispatch (pretty_printer *buffer, const geh_dispatch *gs,
  1194. int spc, dump_flags_t flags)
  1195. {
  1196. if (flags & TDF_RAW)
  1197. dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
  1198. gimple_eh_dispatch_region (gs));
  1199. else
  1200. dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
  1201. gimple_eh_dispatch_region (gs));
  1202. }
  1203. /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
  1204. of indent. FLAGS specifies details to show in the dump (see TDF_*
  1205. in dumpfile.h). */
  1206. static void
  1207. dump_gimple_debug (pretty_printer *buffer, const gdebug *gs, int spc,
  1208. dump_flags_t flags)
  1209. {
  1210. switch (gs->subcode)
  1211. {
  1212. case GIMPLE_DEBUG_BIND:
  1213. if (flags & TDF_RAW)
  1214. dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
  1215. gimple_debug_bind_get_var (gs),
  1216. gimple_debug_bind_get_value (gs));
  1217. else
  1218. dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
  1219. gimple_debug_bind_get_var (gs),
  1220. gimple_debug_bind_get_value (gs));
  1221. break;
  1222. case GIMPLE_DEBUG_SOURCE_BIND:
  1223. if (flags & TDF_RAW)
  1224. dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
  1225. gimple_debug_source_bind_get_var (gs),
  1226. gimple_debug_source_bind_get_value (gs));
  1227. else
  1228. dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
  1229. gimple_debug_source_bind_get_var (gs),
  1230. gimple_debug_source_bind_get_value (gs));
  1231. break;
  1232. case GIMPLE_DEBUG_BEGIN_STMT:
  1233. if (flags & TDF_RAW)
  1234. dump_gimple_fmt (buffer, spc, flags, "%G BEGIN_STMT", gs);
  1235. else
  1236. dump_gimple_fmt (buffer, spc, flags, "# DEBUG BEGIN_STMT");
  1237. break;
  1238. case GIMPLE_DEBUG_INLINE_ENTRY:
  1239. if (flags & TDF_RAW)
  1240. dump_gimple_fmt (buffer, spc, flags, "%G INLINE_ENTRY %T", gs,
  1241. gimple_block (gs)
  1242. ? block_ultimate_origin (gimple_block (gs))
  1243. : NULL_TREE);
  1244. else
  1245. dump_gimple_fmt (buffer, spc, flags, "# DEBUG INLINE_ENTRY %T",
  1246. gimple_block (gs)
  1247. ? block_ultimate_origin (gimple_block (gs))
  1248. : NULL_TREE);
  1249. break;
  1250. default:
  1251. gcc_unreachable ();
  1252. }
  1253. }
  1254. /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
  1255. static void
  1256. dump_gimple_omp_for (pretty_printer *buffer, const gomp_for *gs, int spc,
  1257. dump_flags_t flags)
  1258. {
  1259. size_t i;
  1260. if (flags & TDF_RAW)
  1261. {
  1262. const char *kind;
  1263. switch (gimple_omp_for_kind (gs))
  1264. {
  1265. case GF_OMP_FOR_KIND_FOR:
  1266. kind = "";
  1267. break;
  1268. case GF_OMP_FOR_KIND_DISTRIBUTE:
  1269. kind = " distribute";
  1270. break;
  1271. case GF_OMP_FOR_KIND_TASKLOOP:
  1272. kind = " taskloop";
  1273. break;
  1274. case GF_OMP_FOR_KIND_OACC_LOOP:
  1275. kind = " oacc_loop";
  1276. break;
  1277. case GF_OMP_FOR_KIND_SIMD:
  1278. kind = " simd";
  1279. break;
  1280. default:
  1281. gcc_unreachable ();
  1282. }
  1283. dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
  1284. kind, gimple_omp_body (gs));
  1285. dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
  1286. dump_gimple_fmt (buffer, spc, flags, " >,");
  1287. for (i = 0; i < gimple_omp_for_collapse (gs); i++)
  1288. dump_gimple_fmt (buffer, spc, flags,
  1289. "%+%T, %T, %T, %s, %T,%n",
  1290. gimple_omp_for_index (gs, i),
  1291. gimple_omp_for_initial (gs, i),
  1292. gimple_omp_for_final (gs, i),
  1293. get_tree_code_name (gimple_omp_for_cond (gs, i)),
  1294. gimple_omp_for_incr (gs, i));
  1295. dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
  1296. gimple_omp_for_pre_body (gs));
  1297. }
  1298. else
  1299. {
  1300. switch (gimple_omp_for_kind (gs))
  1301. {
  1302. case GF_OMP_FOR_KIND_FOR:
  1303. pp_string (buffer, "#pragma omp for");
  1304. break;
  1305. case GF_OMP_FOR_KIND_DISTRIBUTE:
  1306. pp_string (buffer, "#pragma omp distribute");
  1307. break;
  1308. case GF_OMP_FOR_KIND_TASKLOOP:
  1309. pp_string (buffer, "#pragma omp taskloop");
  1310. break;
  1311. case GF_OMP_FOR_KIND_OACC_LOOP:
  1312. pp_string (buffer, "#pragma acc loop");
  1313. break;
  1314. case GF_OMP_FOR_KIND_SIMD:
  1315. pp_string (buffer, "#pragma omp simd");
  1316. break;
  1317. case GF_OMP_FOR_KIND_GRID_LOOP:
  1318. pp_string (buffer, "#pragma omp for grid_loop");
  1319. break;
  1320. default:
  1321. gcc_unreachable ();
  1322. }
  1323. dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
  1324. for (i = 0; i < gimple_omp_for_collapse (gs); i++)
  1325. {
  1326. if (i)
  1327. spc += 2;
  1328. newline_and_indent (buffer, spc);
  1329. pp_string (buffer, "for (");
  1330. dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
  1331. flags, false);
  1332. pp_string (buffer, " = ");
  1333. dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
  1334. flags, false);
  1335. pp_string (buffer, "; ");
  1336. dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
  1337. flags, false);
  1338. pp_space (buffer);
  1339. switch (gimple_omp_for_cond (gs, i))
  1340. {
  1341. case LT_EXPR:
  1342. pp_less (buffer);
  1343. break;
  1344. case GT_EXPR:
  1345. pp_greater (buffer);
  1346. break;
  1347. case LE_EXPR:
  1348. pp_less_equal (buffer);
  1349. break;
  1350. case GE_EXPR:
  1351. pp_greater_equal (buffer);
  1352. break;
  1353. case NE_EXPR:
  1354. pp_string (buffer, "!=");
  1355. break;
  1356. default:
  1357. gcc_unreachable ();
  1358. }
  1359. pp_space (buffer);
  1360. dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
  1361. flags, false);
  1362. pp_string (buffer, "; ");
  1363. dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
  1364. flags, false);
  1365. pp_string (buffer, " = ");
  1366. dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
  1367. flags, false);
  1368. pp_right_paren (buffer);
  1369. }
  1370. if (!gimple_seq_empty_p (gimple_omp_body (gs)))
  1371. {
  1372. newline_and_indent (buffer, spc + 2);
  1373. pp_left_brace (buffer);
  1374. pp_newline (buffer);
  1375. dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
  1376. newline_and_indent (buffer, spc + 2);
  1377. pp_right_brace (buffer);
  1378. }
  1379. }
  1380. }
  1381. /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
  1382. static void
  1383. dump_gimple_omp_continue (pretty_printer *buffer, const gomp_continue *gs,
  1384. int spc, dump_flags_t flags)
  1385. {
  1386. if (flags & TDF_RAW)
  1387. {
  1388. dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
  1389. gimple_omp_continue_control_def (gs),
  1390. gimple_omp_continue_control_use (gs));
  1391. }
  1392. else
  1393. {
  1394. pp_string (buffer, "#pragma omp continue (");
  1395. dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
  1396. spc, flags, false);
  1397. pp_comma (buffer);
  1398. pp_space (buffer);
  1399. dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
  1400. spc, flags, false);
  1401. pp_right_paren (buffer);
  1402. }
  1403. }
  1404. /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
  1405. static void
  1406. dump_gimple_omp_single (pretty_printer *buffer, const gomp_single *gs,
  1407. int spc, dump_flags_t flags)
  1408. {
  1409. if (flags & TDF_RAW)
  1410. {
  1411. dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
  1412. gimple_omp_body (gs));
  1413. dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
  1414. dump_gimple_fmt (buffer, spc, flags, " >");
  1415. }
  1416. else
  1417. {
  1418. pp_string (buffer, "#pragma omp single");
  1419. dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
  1420. if (!gimple_seq_empty_p (gimple_omp_body (gs)))
  1421. {
  1422. newline_and_indent (buffer, spc + 2);
  1423. pp_left_brace (buffer);
  1424. pp_newline (buffer);
  1425. dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
  1426. newline_and_indent (buffer, spc + 2);
  1427. pp_right_brace (buffer);
  1428. }
  1429. }
  1430. }
  1431. /* Dump a GIMPLE_OMP_TASKGROUP tuple on the pretty_printer BUFFER. */
  1432. static void
  1433. dump_gimple_omp_taskgroup (pretty_printer *buffer, const gimple *gs,
  1434. int spc, dump_flags_t flags)
  1435. {
  1436. if (flags & TDF_RAW)
  1437. {
  1438. dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
  1439. gimple_omp_body (gs));
  1440. dump_omp_clauses (buffer, gimple_omp_taskgroup_clauses (gs), spc, flags);
  1441. dump_gimple_fmt (buffer, spc, flags, " >");
  1442. }
  1443. else
  1444. {
  1445. pp_string (buffer, "#pragma omp taskgroup");
  1446. dump_omp_clauses (buffer, gimple_omp_taskgroup_clauses (gs), spc, flags);
  1447. if (!gimple_seq_empty_p (gimple_omp_body (gs)))
  1448. {
  1449. newline_and_indent (buffer, spc + 2);
  1450. pp_left_brace (buffer);
  1451. pp_newline (buffer);
  1452. dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
  1453. newline_and_indent (buffer, spc + 2);
  1454. pp_right_brace (buffer);
  1455. }
  1456. }
  1457. }
  1458. /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
  1459. static void
  1460. dump_gimple_omp_target (pretty_printer *buffer, const gomp_target *gs,
  1461. int spc, dump_flags_t flags)
  1462. {
  1463. const char *kind;
  1464. switch (gimple_omp_target_kind (gs))
  1465. {
  1466. case GF_OMP_TARGET_KIND_REGION:
  1467. kind = "";
  1468. break;
  1469. case GF_OMP_TARGET_KIND_DATA:
  1470. kind = " data";
  1471. break;
  1472. case GF_OMP_TARGET_KIND_UPDATE:
  1473. kind = " update";
  1474. break;
  1475. case GF_OMP_TARGET_KIND_ENTER_DATA:
  1476. kind = " enter data";
  1477. break;
  1478. case GF_OMP_TARGET_KIND_EXIT_DATA:
  1479. kind = " exit data";
  1480. break;
  1481. case GF_OMP_TARGET_KIND_OACC_KERNELS:
  1482. kind = " oacc_kernels";
  1483. break;
  1484. case GF_OMP_TARGET_KIND_OACC_PARALLEL:
  1485. kind = " oacc_parallel";
  1486. break;
  1487. case GF_OMP_TARGET_KIND_OACC_SERIAL:
  1488. kind = " oacc_serial";
  1489. break;
  1490. case GF_OMP_TARGET_KIND_OACC_DATA:
  1491. kind = " oacc_data";
  1492. break;
  1493. case GF_OMP_TARGET_KIND_OACC_UPDATE:
  1494. kind = " oacc_update";
  1495. break;
  1496. case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
  1497. kind = " oacc_enter_exit_data";
  1498. break;
  1499. case GF_OMP_TARGET_KIND_OACC_DECLARE:
  1500. kind = " oacc_declare";
  1501. break;
  1502. case GF_OMP_TARGET_KIND_OACC_HOST_DATA:
  1503. kind = " oacc_host_data";
  1504. break;
  1505. default:
  1506. gcc_unreachable ();
  1507. }
  1508. if (flags & TDF_RAW)
  1509. {
  1510. dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
  1511. kind, gimple_omp_body (gs));
  1512. dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
  1513. dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
  1514. gimple_omp_target_child_fn (gs),
  1515. gimple_omp_target_data_arg (gs));
  1516. }
  1517. else
  1518. {
  1519. pp_string (buffer, "#pragma omp target");
  1520. pp_string (buffer, kind);
  1521. dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
  1522. if (gimple_omp_target_child_fn (gs))
  1523. {
  1524. pp_string (buffer, " [child fn: ");
  1525. dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
  1526. spc, flags, false);
  1527. pp_string (buffer, " (");
  1528. if (gimple_omp_target_data_arg (gs))
  1529. dump_generic_node (buffer, gimple_omp_target_data_arg (gs),
  1530. spc, flags, false);
  1531. else
  1532. pp_string (buffer, "???");
  1533. pp_string (buffer, ")]");
  1534. }
  1535. gimple_seq body = gimple_omp_body (gs);
  1536. if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
  1537. {
  1538. newline_and_indent (buffer, spc + 2);
  1539. pp_left_brace (buffer);
  1540. pp_newline (buffer);
  1541. dump_gimple_seq (buffer, body, spc + 4, flags);
  1542. newline_and_indent (buffer, spc + 2);
  1543. pp_right_brace (buffer);
  1544. }
  1545. else if (body)
  1546. {
  1547. pp_newline (buffer);
  1548. dump_gimple_seq (buffer, body, spc + 2, flags);
  1549. }
  1550. }
  1551. }
  1552. /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
  1553. static void
  1554. dump_gimple_omp_teams (pretty_printer *buffer, const gomp_teams *gs, int spc,
  1555. dump_flags_t flags)
  1556. {
  1557. if (flags & TDF_RAW)
  1558. {
  1559. dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
  1560. gimple_omp_body (gs));
  1561. dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
  1562. dump_gimple_fmt (buffer, spc, flags, " >");
  1563. }
  1564. else
  1565. {
  1566. pp_string (buffer, "#pragma omp teams");
  1567. dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
  1568. if (!gimple_seq_empty_p (gimple_omp_body (gs)))
  1569. {
  1570. newline_and_indent (buffer, spc + 2);
  1571. pp_character (buffer, '{');
  1572. pp_newline (buffer);
  1573. dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
  1574. newline_and_indent (buffer, spc + 2);
  1575. pp_character (buffer, '}');
  1576. }
  1577. }
  1578. }
  1579. /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
  1580. static void
  1581. dump_gimple_omp_sections (pretty_printer *buffer, const gomp_sections *gs,
  1582. int spc, dump_flags_t flags)
  1583. {
  1584. if (flags & TDF_RAW)
  1585. {
  1586. dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
  1587. gimple_omp_body (gs));
  1588. dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
  1589. dump_gimple_fmt (buffer, spc, flags, " >");
  1590. }
  1591. else
  1592. {
  1593. pp_string (buffer, "#pragma omp sections");
  1594. if (gimple_omp_sections_control (gs))
  1595. {
  1596. pp_string (buffer, " <");
  1597. dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
  1598. flags, false);
  1599. pp_greater (buffer);
  1600. }
  1601. dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
  1602. if (!gimple_seq_empty_p (gimple_omp_body (gs)))
  1603. {
  1604. newline_and_indent (buffer, spc + 2);
  1605. pp_left_brace (buffer);
  1606. pp_newline (buffer);
  1607. dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
  1608. newline_and_indent (buffer, spc + 2);
  1609. pp_right_brace (buffer);
  1610. }
  1611. }
  1612. }
  1613. /* Dump a GIMPLE_OMP_{MASTER,ORDERED,SECTION} tuple on the
  1614. pretty_printer BUFFER. */
  1615. static void
  1616. dump_gimple_omp_block (pretty_printer *buffer, const gimple *gs, int spc,
  1617. dump_flags_t flags)
  1618. {
  1619. if (flags & TDF_RAW)
  1620. dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
  1621. gimple_omp_body (gs));
  1622. else
  1623. {
  1624. switch (gimple_code (gs))
  1625. {
  1626. case GIMPLE_OMP_MASTER:
  1627. pp_string (buffer, "#pragma omp master");
  1628. break;
  1629. case GIMPLE_OMP_SECTION:
  1630. pp_string (buffer, "#pragma omp section");
  1631. break;
  1632. case GIMPLE_OMP_GRID_BODY:
  1633. pp_string (buffer, "#pragma omp gridified body");
  1634. break;
  1635. default:
  1636. gcc_unreachable ();
  1637. }
  1638. if (!gimple_seq_empty_p (gimple_omp_body (gs)))
  1639. {
  1640. newline_and_indent (buffer, spc + 2);
  1641. pp_left_brace (buffer);
  1642. pp_newline (buffer);
  1643. dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
  1644. newline_and_indent (buffer, spc + 2);
  1645. pp_right_brace (buffer);
  1646. }
  1647. }
  1648. }
  1649. /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
  1650. static void
  1651. dump_gimple_omp_critical (pretty_printer *buffer, const gomp_critical *gs,
  1652. int spc, dump_flags_t flags)
  1653. {
  1654. if (flags & TDF_RAW)
  1655. dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
  1656. gimple_omp_body (gs));
  1657. else
  1658. {
  1659. pp_string (buffer, "#pragma omp critical");
  1660. if (gimple_omp_critical_name (gs))
  1661. {
  1662. pp_string (buffer, " (");
  1663. dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
  1664. flags, false);
  1665. pp_right_paren (buffer);
  1666. }
  1667. dump_omp_clauses (buffer, gimple_omp_critical_clauses (gs), spc, flags);
  1668. if (!gimple_seq_empty_p (gimple_omp_body (gs)))
  1669. {
  1670. newline_and_indent (buffer, spc + 2);
  1671. pp_left_brace (buffer);
  1672. pp_newline (buffer);
  1673. dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
  1674. newline_and_indent (buffer, spc + 2);
  1675. pp_right_brace (buffer);
  1676. }
  1677. }
  1678. }
  1679. /* Dump a GIMPLE_OMP_ORDERED tuple on the pretty_printer BUFFER. */
  1680. static void
  1681. dump_gimple_omp_ordered (pretty_printer *buffer, const gomp_ordered *gs,
  1682. int spc, dump_flags_t flags)
  1683. {
  1684. if (flags & TDF_RAW)
  1685. dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
  1686. gimple_omp_body (gs));
  1687. else
  1688. {
  1689. pp_string (buffer, "#pragma omp ordered");
  1690. dump_omp_clauses (buffer, gimple_omp_ordered_clauses (gs), spc, flags);
  1691. if (!gimple_seq_empty_p (gimple_omp_body (gs)))
  1692. {
  1693. newline_and_indent (buffer, spc + 2);
  1694. pp_left_brace (buffer);
  1695. pp_newline (buffer);
  1696. dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
  1697. newline_and_indent (buffer, spc + 2);
  1698. pp_right_brace (buffer);
  1699. }
  1700. }
  1701. }
  1702. /* Dump a GIMPLE_OMP_SCAN tuple on the pretty_printer BUFFER. */
  1703. static void
  1704. dump_gimple_omp_scan (pretty_printer *buffer, const gomp_scan *gs,
  1705. int spc, dump_flags_t flags)
  1706. {
  1707. if (flags & TDF_RAW)
  1708. dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
  1709. gimple_omp_body (gs));
  1710. else
  1711. {
  1712. if (gimple_omp_scan_clauses (gs))
  1713. {
  1714. pp_string (buffer, "#pragma omp scan");
  1715. dump_omp_clauses (buffer, gimple_omp_scan_clauses (gs), spc, flags);
  1716. }
  1717. if (!gimple_seq_empty_p (gimple_omp_body (gs)))
  1718. {
  1719. newline_and_indent (buffer, spc + 2);
  1720. pp_left_brace (buffer);
  1721. pp_newline (buffer);
  1722. dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
  1723. newline_and_indent (buffer, spc + 2);
  1724. pp_right_brace (buffer);
  1725. }
  1726. }
  1727. }
  1728. /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
  1729. static void
  1730. dump_gimple_omp_return (pretty_printer *buffer, const gimple *gs, int spc,
  1731. dump_flags_t flags)
  1732. {
  1733. if (flags & TDF_RAW)
  1734. {
  1735. dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
  1736. (int) gimple_omp_return_nowait_p (gs));
  1737. if (gimple_omp_return_lhs (gs))
  1738. dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
  1739. gimple_omp_return_lhs (gs));
  1740. else
  1741. dump_gimple_fmt (buffer, spc, flags, ">");
  1742. }
  1743. else
  1744. {
  1745. pp_string (buffer, "#pragma omp return");
  1746. if (gimple_omp_return_nowait_p (gs))
  1747. pp_string (buffer, "(nowait)");
  1748. if (gimple_omp_return_lhs (gs))
  1749. {
  1750. pp_string (buffer, " (set ");
  1751. dump_generic_node (buffer, gimple_omp_return_lhs (gs),
  1752. spc, flags, false);
  1753. pp_character (buffer, ')');
  1754. }
  1755. }
  1756. }
  1757. /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
  1758. static void
  1759. dump_gimple_transaction (pretty_printer *buffer, const gtransaction *gs,
  1760. int spc, dump_flags_t flags)
  1761. {
  1762. unsigned subcode = gimple_transaction_subcode (gs);
  1763. if (flags & TDF_RAW)
  1764. {
  1765. dump_gimple_fmt (buffer, spc, flags,
  1766. "%G [SUBCODE=%x,NORM=%T,UNINST=%T,OVER=%T] "
  1767. "<%+BODY <%S> >",
  1768. gs, subcode, gimple_transaction_label_norm (gs),
  1769. gimple_transaction_label_uninst (gs),
  1770. gimple_transaction_label_over (gs),
  1771. gimple_transaction_body (gs));
  1772. }
  1773. else
  1774. {
  1775. if (subcode & GTMA_IS_OUTER)
  1776. pp_string (buffer, "__transaction_atomic [[outer]]");
  1777. else if (subcode & GTMA_IS_RELAXED)
  1778. pp_string (buffer, "__transaction_relaxed");
  1779. else
  1780. pp_string (buffer, "__transaction_atomic");
  1781. subcode &= ~GTMA_DECLARATION_MASK;
  1782. if (gimple_transaction_body (gs))
  1783. {
  1784. newline_and_indent (buffer, spc + 2);
  1785. pp_left_brace (buffer);
  1786. pp_newline (buffer);
  1787. dump_gimple_seq (buffer, gimple_transaction_body (gs),
  1788. spc + 4, flags);
  1789. newline_and_indent (buffer, spc + 2);
  1790. pp_right_brace (buffer);
  1791. }
  1792. else
  1793. {
  1794. pp_string (buffer, " //");
  1795. if (gimple_transaction_label_norm (gs))
  1796. {
  1797. pp_string (buffer, " NORM=");
  1798. dump_generic_node (buffer, gimple_transaction_label_norm (gs),
  1799. spc, flags, false);
  1800. }
  1801. if (gimple_transaction_label_uninst (gs))
  1802. {
  1803. pp_string (buffer, " UNINST=");
  1804. dump_generic_node (buffer, gimple_transaction_label_uninst (gs),
  1805. spc, flags, false);
  1806. }
  1807. if (gimple_transaction_label_over (gs))
  1808. {
  1809. pp_string (buffer, " OVER=");
  1810. dump_generic_node (buffer, gimple_transaction_label_over (gs),
  1811. spc, flags, false);
  1812. }
  1813. if (subcode)
  1814. {
  1815. pp_string (buffer, " SUBCODE=[ ");
  1816. if (subcode & GTMA_HAVE_ABORT)
  1817. {
  1818. pp_string (buffer, "GTMA_HAVE_ABORT ");
  1819. subcode &= ~GTMA_HAVE_ABORT;
  1820. }
  1821. if (subcode & GTMA_HAVE_LOAD)
  1822. {
  1823. pp_string (buffer, "GTMA_HAVE_LOAD ");
  1824. subcode &= ~GTMA_HAVE_LOAD;
  1825. }
  1826. if (subcode & GTMA_HAVE_STORE)
  1827. {
  1828. pp_string (buffer, "GTMA_HAVE_STORE ");
  1829. subcode &= ~GTMA_HAVE_STORE;
  1830. }
  1831. if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
  1832. {
  1833. pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
  1834. subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
  1835. }
  1836. if (subcode & GTMA_DOES_GO_IRREVOCABLE)
  1837. {
  1838. pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
  1839. subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
  1840. }
  1841. if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
  1842. {
  1843. pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
  1844. subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
  1845. }
  1846. if (subcode)
  1847. pp_printf (buffer, "0x%x ", subcode);
  1848. pp_right_bracket (buffer);
  1849. }
  1850. }
  1851. }
  1852. }
  1853. /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
  1854. indent. FLAGS specifies details to show in the dump (see TDF_* in
  1855. dumpfile.h). */
  1856. static void
  1857. dump_gimple_asm (pretty_printer *buffer, const gasm *gs, int spc,
  1858. dump_flags_t flags)
  1859. {
  1860. unsigned int i, n, f, fields;
  1861. if (flags & TDF_RAW)
  1862. {
  1863. dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
  1864. gimple_asm_string (gs));
  1865. n = gimple_asm_noutputs (gs);
  1866. if (n)
  1867. {
  1868. newline_and_indent (buffer, spc + 2);
  1869. pp_string (buffer, "OUTPUT: ");
  1870. for (i = 0; i < n; i++)
  1871. {
  1872. dump_generic_node (buffer, gimple_asm_output_op (gs, i),
  1873. spc, flags, false);
  1874. if (i < n - 1)
  1875. pp_string (buffer, ", ");
  1876. }
  1877. }
  1878. n = gimple_asm_ninputs (gs);
  1879. if (n)
  1880. {
  1881. newline_and_indent (buffer, spc + 2);
  1882. pp_string (buffer, "INPUT: ");
  1883. for (i = 0; i < n; i++)
  1884. {
  1885. dump_generic_node (buffer, gimple_asm_input_op (gs, i),
  1886. spc, flags, false);
  1887. if (i < n - 1)
  1888. pp_string (buffer, ", ");
  1889. }
  1890. }
  1891. n = gimple_asm_nclobbers (gs);
  1892. if (n)
  1893. {
  1894. newline_and_indent (buffer, spc + 2);
  1895. pp_string (buffer, "CLOBBER: ");
  1896. for (i = 0; i < n; i++)
  1897. {
  1898. dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
  1899. spc, flags, false);
  1900. if (i < n - 1)
  1901. pp_string (buffer, ", ");
  1902. }
  1903. }
  1904. n = gimple_asm_nlabels (gs);
  1905. if (n)
  1906. {
  1907. newline_and_indent (buffer, spc + 2);
  1908. pp_string (buffer, "LABEL: ");
  1909. for (i = 0; i < n; i++)
  1910. {
  1911. dump_generic_node (buffer, gimple_asm_label_op (gs, i),
  1912. spc, flags, false);
  1913. if (i < n - 1)
  1914. pp_string (buffer, ", ");
  1915. }
  1916. }
  1917. newline_and_indent (buffer, spc);
  1918. pp_greater (buffer);
  1919. }
  1920. else
  1921. {
  1922. pp_string (buffer, "__asm__");
  1923. if (gimple_asm_volatile_p (gs))
  1924. pp_string (buffer, " __volatile__");
  1925. if (gimple_asm_inline_p (gs))
  1926. pp_string (buffer, " __inline__");
  1927. if (gimple_asm_nlabels (gs))
  1928. pp_string (buffer, " goto");
  1929. pp_string (buffer, "(\"");
  1930. pp_string (buffer, gimple_asm_string (gs));
  1931. pp_string (buffer, "\"");
  1932. if (gimple_asm_nlabels (gs))
  1933. fields = 4;
  1934. else if (gimple_asm_nclobbers (gs))
  1935. fields = 3;
  1936. else if (gimple_asm_ninputs (gs))
  1937. fields = 2;
  1938. else if (gimple_asm_noutputs (gs))
  1939. fields = 1;
  1940. else
  1941. fields = 0;
  1942. for (f = 0; f < fields; ++f)
  1943. {
  1944. pp_string (buffer, " : ");
  1945. switch (f)
  1946. {
  1947. case 0:
  1948. n = gimple_asm_noutputs (gs);
  1949. for (i = 0; i < n; i++)
  1950. {
  1951. dump_generic_node (buffer, gimple_asm_output_op (gs, i),
  1952. spc, flags, false);
  1953. if (i < n - 1)
  1954. pp_string (buffer, ", ");
  1955. }
  1956. break;
  1957. case 1:
  1958. n = gimple_asm_ninputs (gs);
  1959. for (i = 0; i < n; i++)
  1960. {
  1961. dump_generic_node (buffer, gimple_asm_input_op (gs, i),
  1962. spc, flags, false);
  1963. if (i < n - 1)
  1964. pp_string (buffer, ", ");
  1965. }
  1966. break;
  1967. case 2:
  1968. n = gimple_asm_nclobbers (gs);
  1969. for (i = 0; i < n; i++)
  1970. {
  1971. dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
  1972. spc, flags, false);
  1973. if (i < n - 1)
  1974. pp_string (buffer, ", ");
  1975. }
  1976. break;
  1977. case 3:
  1978. n = gimple_asm_nlabels (gs);
  1979. for (i = 0; i < n; i++)
  1980. {
  1981. dump_generic_node (buffer, gimple_asm_label_op (gs, i),
  1982. spc, flags, false);
  1983. if (i < n - 1)
  1984. pp_string (buffer, ", ");
  1985. }
  1986. break;
  1987. default:
  1988. gcc_unreachable ();
  1989. }
  1990. }
  1991. pp_string (buffer, ");");
  1992. }
  1993. }
  1994. /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
  1995. SPC spaces of indent. */
  1996. static void
  1997. dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
  1998. {
  1999. if (TREE_CODE (node) != SSA_NAME)
  2000. return;
  2001. if (POINTER_TYPE_P (TREE_TYPE (node))
  2002. && SSA_NAME_PTR_INFO (node))
  2003. {
  2004. unsigned int align, misalign;
  2005. struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
  2006. pp_string (buffer, "# PT = ");
  2007. pp_points_to_solution (buffer, &pi->pt);
  2008. newline_and_indent (buffer, spc);
  2009. if (get_ptr_info_alignment (pi, &align, &misalign))
  2010. {
  2011. pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
  2012. newline_and_indent (buffer, spc);
  2013. }
  2014. }
  2015. if (!POINTER_TYPE_P (TREE_TYPE (node))
  2016. && SSA_NAME_RANGE_INFO (node))
  2017. {
  2018. wide_int min, max, nonzero_bits;
  2019. value_range_kind range_type = get_range_info (node, &min, &max);
  2020. if (range_type == VR_VARYING)
  2021. pp_printf (buffer, "# RANGE VR_VARYING");
  2022. else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
  2023. {
  2024. pp_printf (buffer, "# RANGE ");
  2025. pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
  2026. pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
  2027. pp_printf (buffer, ", ");
  2028. pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
  2029. pp_printf (buffer, "]");
  2030. }
  2031. nonzero_bits = get_nonzero_bits (node);
  2032. if (nonzero_bits != -1)
  2033. {
  2034. pp_string (buffer, " NONZERO ");
  2035. pp_wide_int (buffer, nonzero_bits, UNSIGNED);
  2036. }
  2037. newline_and_indent (buffer, spc);
  2038. }
  2039. }
  2040. /* As dump_ssaname_info, but dump to FILE. */
  2041. void
  2042. dump_ssaname_info_to_file (FILE *file, tree node, int spc)
  2043. {
  2044. pretty_printer buffer;
  2045. pp_needs_newline (&buffer) = true;
  2046. buffer.buffer->stream = file;
  2047. dump_ssaname_info (&buffer, node, spc);
  2048. pp_flush (&buffer);
  2049. }
  2050. /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
  2051. The caller is responsible for calling pp_flush on BUFFER to finalize
  2052. pretty printer. If COMMENT is true, print this after #. */
  2053. static void
  2054. dump_gimple_phi (pretty_printer *buffer, const gphi *phi, int spc, bool comment,
  2055. dump_flags_t flags)
  2056. {
  2057. size_t i;
  2058. tree lhs = gimple_phi_result (phi);
  2059. if (flags & TDF_ALIAS)
  2060. dump_ssaname_info (buffer, lhs, spc);
  2061. if (comment)
  2062. pp_string (buffer, "# ");
  2063. if (flags & TDF_RAW)
  2064. dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
  2065. gimple_phi_result (phi));
  2066. else
  2067. {
  2068. dump_generic_node (buffer, lhs, spc, flags, false);
  2069. if (flags & TDF_GIMPLE)
  2070. pp_string (buffer, " = __PHI (");
  2071. else
  2072. pp_string (buffer, " = PHI <");
  2073. }
  2074. for (i = 0; i < gimple_phi_num_args (phi); i++)
  2075. {
  2076. if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
  2077. dump_location (buffer, gimple_phi_arg_location (phi, i));
  2078. basic_block src = gimple_phi_arg_edge (phi, i)->src;
  2079. if (flags & TDF_GIMPLE)
  2080. {
  2081. pp_string (buffer, "__BB");
  2082. pp_decimal_int (buffer, src->index);
  2083. pp_string (buffer, ": ");
  2084. }
  2085. dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
  2086. false);
  2087. if (! (flags & TDF_GIMPLE))
  2088. {
  2089. pp_left_paren (buffer);
  2090. pp_decimal_int (buffer, src->index);
  2091. pp_right_paren (buffer);
  2092. }
  2093. if (i < gimple_phi_num_args (phi) - 1)
  2094. pp_string (buffer, ", ");
  2095. }
  2096. if (flags & TDF_GIMPLE)
  2097. pp_string (buffer, ");");
  2098. else
  2099. pp_greater (buffer);
  2100. }
  2101. /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
  2102. of indent. FLAGS specifies details to show in the dump (see TDF_* in
  2103. dumpfile.h). */
  2104. static void
  2105. dump_gimple_omp_parallel (pretty_printer *buffer, const gomp_parallel *gs,
  2106. int spc, dump_flags_t flags)
  2107. {
  2108. if (flags & TDF_RAW)
  2109. {
  2110. dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
  2111. gimple_omp_body (gs));
  2112. dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
  2113. dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
  2114. gimple_omp_parallel_child_fn (gs),
  2115. gimple_omp_parallel_data_arg (gs));
  2116. }
  2117. else
  2118. {
  2119. gimple_seq body;
  2120. pp_string (buffer, "#pragma omp parallel");
  2121. dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
  2122. if (gimple_omp_parallel_child_fn (gs))
  2123. {
  2124. pp_string (buffer, " [child fn: ");
  2125. dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
  2126. spc, flags, false);
  2127. pp_string (buffer, " (");
  2128. if (gimple_omp_parallel_data_arg (gs))
  2129. dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
  2130. spc, flags, false);
  2131. else
  2132. pp_string (buffer, "???");
  2133. pp_string (buffer, ")]");
  2134. }
  2135. body = gimple_omp_body (gs);
  2136. if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
  2137. {
  2138. newline_and_indent (buffer, spc + 2);
  2139. pp_left_brace (buffer);
  2140. pp_newline (buffer);
  2141. dump_gimple_seq (buffer, body, spc + 4, flags);
  2142. newline_and_indent (buffer, spc + 2);
  2143. pp_right_brace (buffer);
  2144. }
  2145. else if (body)
  2146. {
  2147. pp_newline (buffer);
  2148. dump_gimple_seq (buffer, body, spc + 2, flags);
  2149. }
  2150. }
  2151. }
  2152. /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
  2153. of indent. FLAGS specifies details to show in the dump (see TDF_* in
  2154. dumpfile.h). */
  2155. static void
  2156. dump_gimple_omp_task (pretty_printer *buffer, const gomp_task *gs, int spc,
  2157. dump_flags_t flags)
  2158. {
  2159. if (flags & TDF_RAW)
  2160. {
  2161. dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
  2162. gimple_omp_body (gs));
  2163. dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
  2164. dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
  2165. gimple_omp_task_child_fn (gs),
  2166. gimple_omp_task_data_arg (gs),
  2167. gimple_omp_task_copy_fn (gs),
  2168. gimple_omp_task_arg_size (gs),
  2169. gimple_omp_task_arg_size (gs));
  2170. }
  2171. else
  2172. {
  2173. gimple_seq body;
  2174. if (gimple_omp_task_taskloop_p (gs))
  2175. pp_string (buffer, "#pragma omp taskloop");
  2176. else if (gimple_omp_task_taskwait_p (gs))
  2177. pp_string (buffer, "#pragma omp taskwait");
  2178. else
  2179. pp_string (buffer, "#pragma omp task");
  2180. dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
  2181. if (gimple_omp_task_child_fn (gs))
  2182. {
  2183. pp_string (buffer, " [child fn: ");
  2184. dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
  2185. spc, flags, false);
  2186. pp_string (buffer, " (");
  2187. if (gimple_omp_task_data_arg (gs))
  2188. dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
  2189. spc, flags, false);
  2190. else
  2191. pp_string (buffer, "???");
  2192. pp_string (buffer, ")]");
  2193. }
  2194. body = gimple_omp_body (gs);
  2195. if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
  2196. {
  2197. newline_and_indent (buffer, spc + 2);
  2198. pp_left_brace (buffer);
  2199. pp_newline (buffer);
  2200. dump_gimple_seq (buffer, body, spc + 4, flags);
  2201. newline_and_indent (buffer, spc + 2);
  2202. pp_right_brace (buffer);
  2203. }
  2204. else if (body)
  2205. {
  2206. pp_newline (buffer);
  2207. dump_gimple_seq (buffer, body, spc + 2, flags);
  2208. }
  2209. }
  2210. }
  2211. /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
  2212. spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
  2213. in dumpfile.h). */
  2214. static void
  2215. dump_gimple_omp_atomic_load (pretty_printer *buffer, const gomp_atomic_load *gs,
  2216. int spc, dump_flags_t flags)
  2217. {
  2218. if (flags & TDF_RAW)
  2219. {
  2220. dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
  2221. gimple_omp_atomic_load_lhs (gs),
  2222. gimple_omp_atomic_load_rhs (gs));
  2223. }
  2224. else
  2225. {
  2226. pp_string (buffer, "#pragma omp atomic_load");
  2227. dump_omp_atomic_memory_order (buffer,
  2228. gimple_omp_atomic_memory_order (gs));
  2229. if (gimple_omp_atomic_need_value_p (gs))
  2230. pp_string (buffer, " [needed]");
  2231. newline_and_indent (buffer, spc + 2);
  2232. dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
  2233. spc, flags, false);
  2234. pp_space (buffer);
  2235. pp_equal (buffer);
  2236. pp_space (buffer);
  2237. pp_star (buffer);
  2238. dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
  2239. spc, flags, false);
  2240. }
  2241. }
  2242. /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
  2243. spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
  2244. in dumpfile.h). */
  2245. static void
  2246. dump_gimple_omp_atomic_store (pretty_printer *buffer,
  2247. const gomp_atomic_store *gs, int spc,
  2248. dump_flags_t flags)
  2249. {
  2250. if (flags & TDF_RAW)
  2251. {
  2252. dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
  2253. gimple_omp_atomic_store_val (gs));
  2254. }
  2255. else
  2256. {
  2257. pp_string (buffer, "#pragma omp atomic_store");
  2258. dump_omp_atomic_memory_order (buffer,
  2259. gimple_omp_atomic_memory_order (gs));
  2260. pp_space (buffer);
  2261. if (gimple_omp_atomic_need_value_p (gs))
  2262. pp_string (buffer, "[needed] ");
  2263. pp_left_paren (buffer);
  2264. dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
  2265. spc, flags, false);
  2266. pp_right_paren (buffer);
  2267. }
  2268. }
  2269. /* Dump all the memory operands for statement GS. BUFFER, SPC and
  2270. FLAGS are as in pp_gimple_stmt_1. */
  2271. static void
  2272. dump_gimple_mem_ops (pretty_printer *buffer, const gimple *gs, int spc,
  2273. dump_flags_t flags)
  2274. {
  2275. tree vdef = gimple_vdef (gs);
  2276. tree vuse = gimple_vuse (gs);
  2277. if (vdef != NULL_TREE)
  2278. {
  2279. pp_string (buffer, "# ");
  2280. dump_generic_node (buffer, vdef, spc + 2, flags, false);
  2281. pp_string (buffer, " = VDEF <");
  2282. dump_generic_node (buffer, vuse, spc + 2, flags, false);
  2283. pp_greater (buffer);
  2284. newline_and_indent (buffer, spc);
  2285. }
  2286. else if (vuse != NULL_TREE)
  2287. {
  2288. pp_string (buffer, "# VUSE <");
  2289. dump_generic_node (buffer, vuse, spc + 2, flags, false);
  2290. pp_greater (buffer);
  2291. newline_and_indent (buffer, spc);
  2292. }
  2293. }
  2294. /* Print the gimple statement GS on the pretty printer BUFFER, SPC
  2295. spaces of indent. FLAGS specifies details to show in the dump (see
  2296. TDF_* in dumpfile.h). The caller is responsible for calling
  2297. pp_flush on BUFFER to finalize the pretty printer. */
  2298. void
  2299. pp_gimple_stmt_1 (pretty_printer *buffer, const gimple *gs, int spc,
  2300. dump_flags_t flags)
  2301. {
  2302. if (!gs)
  2303. return;
  2304. if (flags & TDF_STMTADDR)
  2305. pp_printf (buffer, "<&%p> ", (const void *) gs);
  2306. if ((flags & TDF_LINENO) && gimple_has_location (gs))
  2307. dump_location (buffer, gimple_location (gs));
  2308. if (flags & TDF_EH)
  2309. {
  2310. int lp_nr = lookup_stmt_eh_lp (gs);
  2311. if (lp_nr > 0)
  2312. pp_printf (buffer, "[LP %d] ", lp_nr);
  2313. else if (lp_nr < 0)
  2314. pp_printf (buffer, "[MNT %d] ", -lp_nr);
  2315. }
  2316. if ((flags & (TDF_VOPS|TDF_MEMSYMS))
  2317. && gimple_has_mem_ops (gs))
  2318. dump_gimple_mem_ops (buffer, gs, spc, flags);
  2319. if (gimple_has_lhs (gs)
  2320. && (flags & TDF_ALIAS))
  2321. dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
  2322. switch (gimple_code (gs))
  2323. {
  2324. case GIMPLE_ASM:
  2325. dump_gimple_asm (buffer, as_a <const gasm *> (gs), spc, flags);
  2326. break;
  2327. case GIMPLE_ASSIGN:
  2328. dump_gimple_assign (buffer, as_a <const gassign *> (gs), spc, flags);
  2329. break;
  2330. case GIMPLE_BIND:
  2331. dump_gimple_bind (buffer, as_a <const gbind *> (gs), spc, flags);
  2332. break;
  2333. case GIMPLE_CALL:
  2334. dump_gimple_call (buffer, as_a <const gcall *> (gs), spc, flags);
  2335. break;
  2336. case GIMPLE_COND:
  2337. dump_gimple_cond (buffer, as_a <const gcond *> (gs), spc, flags);
  2338. break;
  2339. case GIMPLE_LABEL:
  2340. dump_gimple_label (buffer, as_a <const glabel *> (gs), spc, flags);
  2341. break;
  2342. case GIMPLE_GOTO:
  2343. dump_gimple_goto (buffer, as_a <const ggoto *> (gs), spc, flags);
  2344. break;
  2345. case GIMPLE_NOP:
  2346. pp_string (buffer, "GIMPLE_NOP");
  2347. break;
  2348. case GIMPLE_RETURN:
  2349. dump_gimple_return (buffer, as_a <const greturn *> (gs), spc, flags);
  2350. break;
  2351. case GIMPLE_SWITCH:
  2352. dump_gimple_switch (buffer, as_a <const gswitch *> (gs), spc, flags);
  2353. break;
  2354. case GIMPLE_TRY:
  2355. dump_gimple_try (buffer, as_a <const gtry *> (gs), spc, flags);
  2356. break;
  2357. case GIMPLE_PHI:
  2358. dump_gimple_phi (buffer, as_a <const gphi *> (gs), spc, false, flags);
  2359. break;
  2360. case GIMPLE_OMP_PARALLEL:
  2361. dump_gimple_omp_parallel (buffer, as_a <const gomp_parallel *> (gs), spc,
  2362. flags);
  2363. break;
  2364. case GIMPLE_OMP_TASK:
  2365. dump_gimple_omp_task (buffer, as_a <const gomp_task *> (gs), spc, flags);
  2366. break;
  2367. case GIMPLE_OMP_ATOMIC_LOAD:
  2368. dump_gimple_omp_atomic_load (buffer, as_a <const gomp_atomic_load *> (gs),
  2369. spc, flags);
  2370. break;
  2371. case GIMPLE_OMP_ATOMIC_STORE:
  2372. dump_gimple_omp_atomic_store (buffer,
  2373. as_a <const gomp_atomic_store *> (gs),
  2374. spc, flags);
  2375. break;
  2376. case GIMPLE_OMP_FOR:
  2377. dump_gimple_omp_for (buffer, as_a <const gomp_for *> (gs), spc, flags);
  2378. break;
  2379. case GIMPLE_OMP_CONTINUE:
  2380. dump_gimple_omp_continue (buffer, as_a <const gomp_continue *> (gs), spc,
  2381. flags);
  2382. break;
  2383. case GIMPLE_OMP_SINGLE:
  2384. dump_gimple_omp_single (buffer, as_a <const gomp_single *> (gs), spc,
  2385. flags);
  2386. break;
  2387. case GIMPLE_OMP_TARGET:
  2388. dump_gimple_omp_target (buffer, as_a <const gomp_target *> (gs), spc,
  2389. flags);
  2390. break;
  2391. case GIMPLE_OMP_TEAMS:
  2392. dump_gimple_omp_teams (buffer, as_a <const gomp_teams *> (gs), spc,
  2393. flags);
  2394. break;
  2395. case GIMPLE_OMP_RETURN:
  2396. dump_gimple_omp_return (buffer, gs, spc, flags);
  2397. break;
  2398. case GIMPLE_OMP_SECTIONS:
  2399. dump_gimple_omp_sections (buffer, as_a <const gomp_sections *> (gs),
  2400. spc, flags);
  2401. break;
  2402. case GIMPLE_OMP_SECTIONS_SWITCH:
  2403. pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
  2404. break;
  2405. case GIMPLE_OMP_TASKGROUP:
  2406. dump_gimple_omp_taskgroup (buffer, gs, spc, flags);
  2407. break;
  2408. case GIMPLE_OMP_MASTER:
  2409. case GIMPLE_OMP_SECTION:
  2410. case GIMPLE_OMP_GRID_BODY:
  2411. dump_gimple_omp_block (buffer, gs, spc, flags);
  2412. break;
  2413. case GIMPLE_OMP_ORDERED:
  2414. dump_gimple_omp_ordered (buffer, as_a <const gomp_ordered *> (gs), spc,
  2415. flags);
  2416. break;
  2417. case GIMPLE_OMP_SCAN:
  2418. dump_gimple_omp_scan (buffer, as_a <const gomp_scan *> (gs), spc,
  2419. flags);
  2420. break;
  2421. case GIMPLE_OMP_CRITICAL:
  2422. dump_gimple_omp_critical (buffer, as_a <const gomp_critical *> (gs), spc,
  2423. flags);
  2424. break;
  2425. case GIMPLE_CATCH:
  2426. dump_gimple_catch (buffer, as_a <const gcatch *> (gs), spc, flags);
  2427. break;
  2428. case GIMPLE_EH_FILTER:
  2429. dump_gimple_eh_filter (buffer, as_a <const geh_filter *> (gs), spc,
  2430. flags);
  2431. break;
  2432. case GIMPLE_EH_MUST_NOT_THROW:
  2433. dump_gimple_eh_must_not_throw (buffer,
  2434. as_a <const geh_mnt *> (gs),
  2435. spc, flags);
  2436. break;
  2437. case GIMPLE_EH_ELSE:
  2438. dump_gimple_eh_else (buffer, as_a <const geh_else *> (gs), spc, flags);
  2439. break;
  2440. case GIMPLE_RESX:
  2441. dump_gimple_resx (buffer, as_a <const gresx *> (gs), spc, flags);
  2442. break;
  2443. case GIMPLE_EH_DISPATCH:
  2444. dump_gimple_eh_dispatch (buffer, as_a <const geh_dispatch *> (gs), spc,
  2445. flags);
  2446. break;
  2447. case GIMPLE_DEBUG:
  2448. dump_gimple_debug (buffer, as_a <const gdebug *> (gs), spc, flags);
  2449. break;
  2450. case GIMPLE_PREDICT:
  2451. pp_string (buffer, "// predicted ");
  2452. if (gimple_predict_outcome (gs))
  2453. pp_string (buffer, "likely by ");
  2454. else
  2455. pp_string (buffer, "unlikely by ");
  2456. pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
  2457. pp_string (buffer, " predictor.");
  2458. break;
  2459. case GIMPLE_TRANSACTION:
  2460. dump_gimple_transaction (buffer, as_a <const gtransaction *> (gs), spc,
  2461. flags);
  2462. break;
  2463. default:
  2464. GIMPLE_NIY;
  2465. }
  2466. }
  2467. /* Dumps header of basic block BB to OUTF indented by INDENT
  2468. spaces and details described by flags. */
  2469. static void
  2470. dump_gimple_bb_header (FILE *outf, basic_block bb, int indent,
  2471. dump_flags_t flags)
  2472. {
  2473. if (flags & TDF_BLOCKS)
  2474. {
  2475. if (flags & TDF_LINENO)
  2476. {
  2477. gimple_stmt_iterator gsi;
  2478. fputs (";; ", outf);
  2479. for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
  2480. if (!is_gimple_debug (gsi_stmt (gsi))
  2481. && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
  2482. {
  2483. fprintf (outf, "%*sstarting at line %d",
  2484. indent, "", get_lineno (gsi_stmt (gsi)));
  2485. break;
  2486. }
  2487. if (bb->discriminator)
  2488. fprintf (outf, ", discriminator %i", bb->discriminator);
  2489. fputc ('\n', outf);
  2490. }
  2491. }
  2492. else
  2493. {
  2494. if (flags & TDF_GIMPLE)
  2495. {
  2496. fprintf (outf, "%*s__BB(%d", indent, "", bb->index);
  2497. if (bb->loop_father->header == bb)
  2498. fprintf (outf, ",loop_header(%d)", bb->loop_father->num);
  2499. if (bb->count.initialized_p ())
  2500. fprintf (outf, ",%s(%d)",
  2501. profile_quality_as_string (bb->count.quality ()),
  2502. bb->count.value ());
  2503. fprintf (outf, "):\n");
  2504. }
  2505. else
  2506. fprintf (outf, "%*s<bb %d> %s:\n",
  2507. indent, "", bb->index, dump_profile (bb->count));
  2508. }
  2509. }
  2510. /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
  2511. spaces. */
  2512. static void
  2513. dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
  2514. basic_block bb ATTRIBUTE_UNUSED,
  2515. int indent ATTRIBUTE_UNUSED,
  2516. dump_flags_t flags ATTRIBUTE_UNUSED)
  2517. {
  2518. /* There is currently no GIMPLE-specific basic block info to dump. */
  2519. return;
  2520. }
  2521. /* Dump PHI nodes of basic block BB to BUFFER with details described
  2522. by FLAGS and indented by INDENT spaces. */
  2523. static void
  2524. dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent,
  2525. dump_flags_t flags)
  2526. {
  2527. gphi_iterator i;
  2528. for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
  2529. {
  2530. gphi *phi = i.phi ();
  2531. if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
  2532. {
  2533. INDENT (indent);
  2534. dump_gimple_phi (buffer, phi, indent,
  2535. (flags & TDF_GIMPLE) ? false : true, flags);
  2536. pp_newline (buffer);
  2537. }
  2538. }
  2539. }
  2540. /* Dump jump to basic block BB that is represented implicitly in the cfg
  2541. to BUFFER. */
  2542. static void
  2543. pp_cfg_jump (pretty_printer *buffer, edge e, dump_flags_t flags)
  2544. {
  2545. if (flags & TDF_GIMPLE)
  2546. {
  2547. pp_string (buffer, "goto __BB");
  2548. pp_decimal_int (buffer, e->dest->index);
  2549. if (e->probability.initialized_p ())
  2550. {
  2551. pp_string (buffer, "(");
  2552. pp_string (buffer,
  2553. profile_quality_as_string (e->probability.quality ()));
  2554. pp_string (buffer, "(");
  2555. pp_decimal_int (buffer, e->probability.value ());
  2556. pp_string (buffer, "))");
  2557. }
  2558. pp_semicolon (buffer);
  2559. }
  2560. else
  2561. {
  2562. pp_string (buffer, "goto <bb ");
  2563. pp_decimal_int (buffer, e->dest->index);
  2564. pp_greater (buffer);
  2565. pp_semicolon (buffer);
  2566. dump_edge_probability (buffer, e);
  2567. }
  2568. }
  2569. /* Dump edges represented implicitly in basic block BB to BUFFER, indented
  2570. by INDENT spaces, with details given by FLAGS. */
  2571. static void
  2572. dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
  2573. dump_flags_t flags)
  2574. {
  2575. edge e;
  2576. gimple *stmt;
  2577. stmt = last_stmt (bb);
  2578. if (stmt && gimple_code (stmt) == GIMPLE_COND)
  2579. {
  2580. edge true_edge, false_edge;
  2581. /* When we are emitting the code or changing CFG, it is possible that
  2582. the edges are not yet created. When we are using debug_bb in such
  2583. a situation, we do not want it to crash. */
  2584. if (EDGE_COUNT (bb->succs) != 2)
  2585. return;
  2586. extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
  2587. INDENT (indent + 2);
  2588. pp_cfg_jump (buffer, true_edge, flags);
  2589. newline_and_indent (buffer, indent);
  2590. pp_string (buffer, "else");
  2591. newline_and_indent (buffer, indent + 2);
  2592. pp_cfg_jump (buffer, false_edge, flags);
  2593. pp_newline (buffer);
  2594. return;
  2595. }
  2596. /* If there is a fallthru edge, we may need to add an artificial
  2597. goto to the dump. */
  2598. e = find_fallthru_edge (bb->succs);
  2599. if (e && (e->dest != bb->next_bb || (flags & TDF_GIMPLE)))
  2600. {
  2601. INDENT (indent);
  2602. if ((flags & TDF_LINENO)
  2603. && e->goto_locus != UNKNOWN_LOCATION)
  2604. dump_location (buffer, e->goto_locus);
  2605. pp_cfg_jump (buffer, e, flags);
  2606. pp_newline (buffer);
  2607. }
  2608. }
  2609. /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
  2610. indented by INDENT spaces. */
  2611. static void
  2612. gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
  2613. dump_flags_t flags)
  2614. {
  2615. gimple_stmt_iterator gsi;
  2616. gimple *stmt;
  2617. int label_indent = indent - 2;
  2618. if (label_indent < 0)
  2619. label_indent = 0;
  2620. dump_phi_nodes (buffer, bb, indent, flags);
  2621. for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
  2622. {
  2623. int curr_indent;
  2624. stmt = gsi_stmt (gsi);
  2625. curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
  2626. INDENT (curr_indent);
  2627. pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
  2628. pp_newline_and_flush (buffer);
  2629. gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
  2630. dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
  2631. pp_buffer (buffer)->stream, stmt);
  2632. }
  2633. dump_implicit_edges (buffer, bb, indent, flags);
  2634. pp_flush (buffer);
  2635. }
  2636. /* Dumps basic block BB to FILE with details described by FLAGS and
  2637. indented by INDENT spaces. */
  2638. void
  2639. gimple_dump_bb (FILE *file, basic_block bb, int indent, dump_flags_t flags)
  2640. {
  2641. dump_gimple_bb_header (file, bb, indent, flags);
  2642. if (bb->index >= NUM_FIXED_BLOCKS)
  2643. {
  2644. pretty_printer buffer;
  2645. pp_needs_newline (&buffer) = true;
  2646. buffer.buffer->stream = file;
  2647. gimple_dump_bb_buff (&buffer, bb, indent, flags);
  2648. }
  2649. dump_gimple_bb_footer (file, bb, indent, flags);
  2650. }
  2651. /* Dumps basic block BB to pretty-printer PP with default dump flags and
  2652. no indentation, for use as a label of a DOT graph record-node.
  2653. ??? Should just use gimple_dump_bb_buff here, except that value profiling
  2654. histogram dumping doesn't know about pretty-printers. */
  2655. void
  2656. gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
  2657. {
  2658. pp_printf (pp, "<bb %d>:\n", bb->index);
  2659. pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
  2660. for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
  2661. gsi_next (&gsi))
  2662. {
  2663. gphi *phi = gsi.phi ();
  2664. if (!virtual_operand_p (gimple_phi_result (phi))
  2665. || (dump_flags & TDF_VOPS))
  2666. {
  2667. pp_bar (pp);
  2668. pp_write_text_to_stream (pp);
  2669. pp_string (pp, "# ");
  2670. pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
  2671. pp_newline (pp);
  2672. pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
  2673. }
  2674. }
  2675. for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
  2676. gsi_next (&gsi))
  2677. {
  2678. gimple *stmt = gsi_stmt (gsi);
  2679. pp_bar (pp);
  2680. pp_write_text_to_stream (pp);
  2681. pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
  2682. pp_newline (pp);
  2683. pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
  2684. }
  2685. dump_implicit_edges (pp, bb, 0, dump_flags);
  2686. pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
  2687. }
  2688. /* Handle the %G format for TEXT. Same as %K in handle_K_format in
  2689. tree-pretty-print.c but with a Gimple statement as an argument. */
  2690. void
  2691. percent_G_format (text_info *text)
  2692. {
  2693. gimple *stmt = va_arg (*text->args_ptr, gimple*);
  2694. /* Fall back on the rich location if the statement doesn't have one. */
  2695. location_t loc = gimple_location (stmt);
  2696. if (loc == UNKNOWN_LOCATION)
  2697. loc = text->m_richloc->get_loc ();
  2698. tree block = gimple_block (stmt);
  2699. percent_K_format (text, loc, block);
  2700. }
  2701. #if __GNUC__ >= 10
  2702. # pragma GCC diagnostic pop
  2703. #endif