From: "Dan'l Miller" <optikos@verizon.net>
Subject: Re: Ada case-statement
Date: Wed, 14 Mar 2018 20:10:09 -0700 (PDT)
Date: 2018-03-14T20:10:09-07:00 [thread overview]
Message-ID: <76eeca56-3246-49d2-baf3-0879741e7e12@googlegroups.com> (raw)
In-Reply-To: <p8cgeh$1v7d$1@gioia.aioe.org>
On Wednesday, March 14, 2018 at 7:57:57 PM UTC-5, Robert Eachus wrote:
> The compiler probably will convert to an if statement,
For dense case statements that utilize all or most of an enumerated type's enumerated values, a jump table is the most likely on most processors to achieve O(1) growth [instead of if-statement-based O(n) growth, where n is the quantity of enumerated values in an enumerated type].
https://stackoverflow.com/questions/39875452/assembly-jump-branch-lookup-tables-instead-of-lots-of-cmp-je
In IA-32, a jump table can be transliterated fairly directly from a case-statement over a dense utilization of an enumerated type. Indeed, if the quantity of enumerated values in the enumerated type is small enough, a case statement that sparsely utilizes only a relative few of the enumerated values also can be transliterated to a jump table, where the unmentioned enumerated values conflate to unhandled case.
jmp [jump_table + si]
jump_table:
dw .F_1, .F_2, ...
next prev parent reply other threads:[~2018-03-15 3:10 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-14 17:35 Ada case-statement Stephen Davies
2018-03-14 17:49 ` Dmitry A. Kazakov
2018-03-15 0:57 ` Robert I. Eachus
2018-03-15 3:10 ` Dan'l Miller [this message]
2018-03-15 5:54 ` J-P. Rosen
2018-03-15 7:56 ` Niklas Holsti
2018-03-15 12:21 ` Dan'l Miller
2018-03-15 17:22 ` Mill processor (Was: Re: Ada case-statement) Niklas Holsti
2018-03-15 21:50 ` Ada case-statement Randy Brukardt
2018-03-14 22:22 ` Mehdi Saada
2018-03-14 23:16 ` Randy Brukardt
2018-03-15 5:04 ` gautier_niouzes
2018-03-15 7:50 ` Jacob Sparre Andersen
2018-03-15 22:05 ` Randy Brukardt
2018-03-15 8:37 ` Dmitry A. Kazakov
2018-03-15 22:20 ` Randy Brukardt
2018-03-16 8:54 ` Dmitry A. Kazakov
2018-03-16 23:49 ` Randy Brukardt
2018-03-17 7:59 ` Dmitry A. Kazakov
2018-03-15 15:37 ` Stephen Davies
2018-03-15 16:33 ` J-P. Rosen
2018-03-15 17:01 ` Dmitry A. Kazakov
2018-03-15 18:41 ` Shark8
2018-03-15 21:12 ` Jeffrey R. Carter
2018-03-18 5:41 ` Robert I. Eachus
2018-03-18 6:57 ` Spiros Bousbouras
2018-03-18 9:17 ` Jeffrey R. Carter
2018-03-18 12:53 ` Simon Wright
2018-03-15 18:50 ` Jere
2018-03-15 20:40 ` Anh Vo
2018-03-15 22:24 ` Randy Brukardt
2018-03-16 9:53 ` Stephen Davies
2018-04-03 17:56 ` marciant
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox