summaryrefslogtreecommitdiff
path: root/includes/Stg.h
diff options
context:
space:
mode:
authorSergei Trofimovich <slyfox@gentoo.org>2017-04-24 09:41:35 -0400
committerBen Gamari <ben@smart-cactus.org>2017-04-24 12:53:43 -0400
commitb68697e579d38ca29c2b84377dc2affa04659a28 (patch)
tree3d7a9f8c888baad175c81863d5519fb42e817770 /includes/Stg.h
parentd5cb4d2b7fab89ea1c3fc74da2317f86e75816ea (diff)
downloadhaskell-b68697e579d38ca29c2b84377dc2affa04659a28.tar.gz
compiler/cmm/PprC.hs: constify labels in .rodata
Consider one-line module module B (v) where v = "hello" in -fvia-C mode it generates code like static char gibberish_str[] = "hello"; It resides in data section (precious resource on ia64!). The patch switches genrator to emit: static const char gibberish_str[] = "hello"; Other types if symbols that gained 'const' qualifier are: - info tables (from haskell and CMM) - static reference tables (from haskell and CMM) Cleanups along the way: - fixed info tables defined in .cmm to reside in .rodata - split out closure declaration into 'IC_' / 'EC_' - added label declaration (based on label type) right before each label definition (based on section type) so that C compiler could check if declaration and definition matches at definition site. Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> Test Plan: ran testsuite on unregisterised x86_64 compiler Reviewers: simonmar, ezyang, austin, bgamari, erikd Reviewed By: bgamari, erikd Subscribers: rwbarton, thomie GHC Trac Issues: #8996 Differential Revision: https://phabricator.haskell.org/D3481
Diffstat (limited to 'includes/Stg.h')
-rw-r--r--includes/Stg.h22
1 files changed, 16 insertions, 6 deletions
diff --git a/includes/Stg.h b/includes/Stg.h
index ff5e3174c0..063959d880 100644
--- a/includes/Stg.h
+++ b/includes/Stg.h
@@ -222,13 +222,23 @@ typedef StgInt I_;
typedef StgWord StgWordArray[];
typedef StgFunPtr F_;
-#define EB_(X) extern char X[]
-#define IB_(X) static char X[]
-#define EI_(X) extern StgWordArray (X) GNU_ATTRIBUTE(aligned (8))
-#define II_(X) static StgWordArray (X) GNU_ATTRIBUTE(aligned (8))
+/* byte arrays (and strings): */
+#define EB_(X) extern const char X[]
+#define IB_(X) static const char X[]
+/* static (non-heap) closures (requires alignment for pointer tagging): */
+#define EC_(X) extern StgWordArray (X) GNU_ATTRIBUTE(aligned (8))
+#define IC_(X) static StgWordArray (X) GNU_ATTRIBUTE(aligned (8))
+/* writable data (does not require alignment): */
+#define ERW_(X) extern StgWordArray (X)
+#define IRW_(X) static StgWordArray (X)
+/* read-only data (does not require alignment): */
+#define ERO_(X) extern const StgWordArray (X)
+#define IRO_(X) static const StgWordArray (X)
+/* stg-native functions: */
#define IF_(f) static StgFunPtr GNUC3_ATTRIBUTE(used) f(void)
-#define FN_(f) StgFunPtr f(void)
-#define EF_(f) StgFunPtr f(void) /* External Cmm functions */
+#define FN_(f) StgFunPtr f(void)
+#define EF_(f) StgFunPtr f(void) /* External Cmm functions */
+/* foreign functions: */
#define EFF_(f) void f() /* See Note [External function prototypes] */
/* Note [External function prototypes] See Trac #8965, #11395