aboutsummaryrefslogtreecommitdiff
path: root/gcc/go/gofrontend/expressions.h
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2019-06-21 14:14:58 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2019-06-21 14:14:58 +0000
commitc9b236e5cafaea9d09ff8102140c72eb3d70e302 (patch)
treedaa083891ba7e3c96f4ac7419562dc67146822a6 /gcc/go/gofrontend/expressions.h
parent050e182a757bdf227a7e2425f06f9e2fd4dff8cb (diff)
downloadgcc-c9b236e5cafaea9d09ff8102140c72eb3d70e302.zip
gcc-c9b236e5cafaea9d09ff8102140c72eb3d70e302.tar.gz
gcc-c9b236e5cafaea9d09ff8102140c72eb3d70e302.tar.bz2
compiler: open code string slice expressions
Currently a string slice expression is implemented with a runtime call __go_string_slice. Change it to open code it, which is more efficient, and allows the backend to further optimize it. Also omit the write barrier for length-only update (i.e. s = s[:n]). Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/182540 From-SVN: r272549
Diffstat (limited to 'gcc/go/gofrontend/expressions.h')
-rw-r--r--gcc/go/gofrontend/expressions.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/go/gofrontend/expressions.h b/gcc/go/gofrontend/expressions.h
index 38dee04..2c505a9 100644
--- a/gcc/go/gofrontend/expressions.h
+++ b/gcc/go/gofrontend/expressions.h
@@ -3133,6 +3133,18 @@ class String_index_expression : public Expression
string() const
{ return this->string_; }
+ // Return the index of a simple index expression, or the start index
+ // of a slice expression.
+ Expression*
+ start() const
+ { return this->start_; }
+
+ // Return the end index of a slice expression. This is NULL for a
+ // simple index expression.
+ Expression*
+ end() const
+ { return this->end_; }
+
protected:
int
do_traverse(Traverse*);